aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/test_helper.rb
Commit message (Collapse)AuthorAgeFilesLines
* DRY in `assert_enqueued_jobs`bogdanvlviv2018-08-201-2/+6
|
* Fix formatting of `ActiveJob::TestHelper` api docsbogdanvlviv2018-08-201-4/+4
|
* Allow `assert_performed_with` to be called without a block.bogdanvlviv2018-08-201-7/+34
| | | | | | | | | | | | | | | Example: ``` def test_assert_performed_with MyJob.perform_later(1,2,3) perform_enqueued_jobs assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high') end ``` Follow up #33626.
* Fix `assert_performed_jobs` and `assert_no_performed_jobs`bogdanvlviv2018-08-201-14/+28
| | | | | Execution of `assert_performed_jobs`, and `assert_no_performed_jobs` without a block should respect passed `:except`, `:only`, and `:queue` options.
* Allow `:queue` option to `assert_no_performed_jobs`.bogdanvlviv2018-08-201-2/+11
| | | | | | | | | | | | | | If the `:queue` option is specified, then only the job(s) enqueued to a specific queue will not be performed. Example: ``` def test_assert_no_performed_jobs_with_queue_option assert_no_performed_jobs queue: :some_queue do HelloJob.set(queue: :other_queue).perform_later("jeremy") end end ```
* Allow `:queue` option to `assert_performed_jobs`.bogdanvlviv2018-08-201-2/+12
| | | | | | | | | | | | | | | If the `:queue` option is specified, then only the job(s) enqueued to a specific queue will be performed. Example: ``` def test_assert_performed_jobs_with_queue_option assert_performed_jobs 1, queue: :some_queue do HelloJob.set(queue: :some_queue).perform_later("jeremy") HelloJob.set(queue: :other_queue).perform_later("bogdan") end end ```
* Fix `perform_enqueued_jobs`bogdanvlviv2018-08-201-1/+4
| | | | | | | | | | | | | Set ```` queue_adapter.perform_enqueued_jobs = true queue_adapter.perform_enqueued_at_jobs = true queue_adapter.filter = only queue_adapter.reject = except queue_adapter.queue = queue ``` if block given. Execution of `flush_enqueued_jobs` doesn't require that.
* Allow `:queue` option to `perform_enqueued_jobs`.bogdanvlviv2018-08-201-4/+18
| | | | | | | | | | | | | | | | | | | | If the `:queue` option is specified, then only the job(s) enqueued to a specific queue will be performed. Example: ``` def test_perform_enqueued_jobs_with_queue perform_enqueued_jobs queue: :some_queue do MyJob.set(queue: :some_queue).perform_later(1, 2, 3) # will be performed HelloJob.set(queue: :other_queue).perform_later(1, 2, 3) # will not be performed end assert_performed_jobs 1 end ``` Follow up #33265 [bogdanvlviv & Jeremy Daer]
* Add example `perform_enqueued_jobs` without block to api docs [ci skip]bogdanvlviv2018-08-161-0/+8
| | | | Follow up #33626
* Allow `perform_enqueued_jobs` to be called without a block.Kevin Deisz2018-08-151-6/+21
| | | | Performs all of the jobs that have been enqueued up to this point in the test.
* Allow `queue` option to `assert_no_enqueued_jobs`bogdanvlviv2018-06-301-2/+10
| | | | | | | | | | | It can be asserted that no jobs are enqueued to a specific queue: ```ruby def test_no_logging assert_no_enqueued_jobs queue: 'default' do LoggingJob.set(queue: :some_queue).perform_later end end ```
* Clarify activejob/lib/active_job/test_helper.rbbogdanvlviv2018-06-291-2/+2
| | | | | | | | | | | Rename `in_block_job` to `enqueued_job` since this variable can refer not only to jobs that were created in the block. See #33258. Return back accidentally removed test to activejob/test/cases/test_helper_test.rb See #33258. Fix name of tests.
* Allow call `assert_enqueued_with` and `assert_enqueued_email_with` with no blockbogdanvlviv2018-06-291-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Example of `assert_enqueued_with` with no block ```ruby def test_assert_enqueued_with MyJob.perform_later(1,2,3) assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') MyJob.set(wait_until: Date.tomorrow.noon).perform_later assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon) end ``` Example of `assert_enqueued_email_with` with no block: ```ruby def test_email ContactMailer.welcome.deliver_later assert_enqueued_email_with ContactMailer, :welcome end def test_email_with_arguments ContactMailer.welcome("Hello", "Goodbye").deliver_later assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"] end ``` Related to #33243
* Revert "Merge pull request #33243 from ↵Rafael Mendonça França2018-06-281-1/+1
| | | | | | | | | evopark/fix/action-mailer-test-helper-no-block" This reverts commit 9d6bbf4e0b2d2b2e2fccd87a778de2893bb28a25, reversing changes made to 5a1ea09062eaed78e21253a128d433a1beb745ad. This method only works with block.
* Fix ActionMailer assert_enqueued_email_withMarcus Ilgner2018-06-281-1/+1
| | | | | | The documentation for assert_enqueued_email_with states that it's supposed to work without a block yet it calls assert_enqueued_with which doesn't check whether a block was passed before calling `yield`
* Use `ArgumentError` instead of own error classyuuji.yaginuma2017-07-201-2/+1
| | | | | If the argument is invalid, I think that it is more intuitive to use `ArgumentError` than its own error class.
* Fix `warning: circular argument reference`yuuji.yaginuma2017-07-191-2/+2
| | | | | | | | | This fixes the following warnings: ``` rails/activejob/lib/active_job/test_helper.rb:119: warning: circular argument reference - except rails/activejob/lib/active_job/test_helper.rb:166: warning: circular argument reference - except ```
* Add `except` option for ActiveJob::TestHelper methodsposthumanism2017-07-181-13/+73
|
* [Active Job] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveJobKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* correctly set test adapter when configure the queue adapter on a per job ↵Yuji Yaginuma2017-01-311-10/+35
| | | | | | | | | | | | (#26690) The `ActiveJob::TestHelper` replace the adapter to test adapter in `before_setup`. It gets the target class using the `descendants`, but if the test target job class is not loaded, will not be a replacement of the adapter. Therefore, instead of replacing with `before_setup`, modified to replace when setting adapter. Fixes #26360
* Merge pull request #27624 from elfassy/assert_enqueued_jobs_with_queue_levelGuillermo Iguaran2017-01-191-10/+24
|\ | | | | Specify the queue to be used with assert_enqueued_jobs
| * assert_enqueued_jobs with queue optionMichael Elfassy2017-01-181-10/+24
| |
* | s/perfomed/performed/Akira Matsuda2017-01-171-1/+1
|/ | | | [ci skip]
* No need to nodoc private methodsAkira Matsuda2016-12-241-5/+5
|
* remove Ruby warning from Active Job test helper methodsyuuji.yaginuma2016-11-181-4/+4
| | | | | | | | | This removes the following warnings. ``` /home/travis/build/rails/rails/activejob/lib/active_job/test_helper.rb:241: warning: shadowing outer local variable - job /home/travis/build/rails/rails/activejob/lib/active_job/test_helper.rb:265: warning: shadowing outer local variable - job ```
* Use named parameters instead of `assert_valid_keys`Maxime Boisvert2016-11-161-8/+8
|
* Add examples of queue_adapter and perform_enqueued jobs to API Docs.Gabi Stefanini2016-10-211-0/+24
|
* use `descendants` to get class that inherited `ActiveJob::Base`yuuji.yaginuma2016-09-051-1/+1
| | | | | | `subclasses` get only child classes. Therefore, if create a job common parent class as `ApplicationJob`, inherited class does not get properly.
* applies new string literal convention in activejob/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Provide the ability to override the queue adapter used by jobs underSteve Lounsbury2016-06-111-1/+14
| | | | | | | | | | | | | test. This PR adds a method called `queue_adapter_for_test` to `ActiveJob::TestHelper`. This method is expected to provide the queue adapter to be used for jobs under test. It maintains the current behaviour by defaulting to an instance of `ActiveJob::QueueAdapter::TestAdapter`. Tests that include `ActiveJob::TestHelper` or extend from `ActiveJob::TestCase` can provide a custom queue adapter by overriding `queue_adapter_for_test` in their class.
* update `assert_no_performed_jobs` doc to use `assert_no_performed_jobs` ↵yuuji.yaginuma2016-03-301-18/+5
| | | | method [ci skip]
* Do not define methods in the included blockRafael Mendonça França2016-02-241-293/+289
| | | | Instance methods can be defined in the module itself
* fix typo in `assert_enqueued_jobs` example [ci skip]yuuji.yaginuma2016-02-071-1/+1
|
* Added missing specs for not modifying queues when using AJ test helpersWojciech Wnętrzak2015-10-071-14/+10
|
* Fixed serializing `:at` option for `assert_enqueued_with` and ↵Wojciech Wnętrzak2015-10-031-4/+11
| | | | `assert_performed_with`
* Support passing array to `assert_enqueued_jobs` in `:only` optionWojciech Wnętrzak2015-10-031-1/+1
|
* Do not document private methods in AJ::TestHelperWojciech Wnętrzak2015-10-021-5/+5
| | | | [CI skip]
* Fix typo on method nameRafael Mendonça França2015-08-161-3/+3
| | | | [Robin Dupret]
* Make assert_enqueued_with and assert_performed_with returns the matched jobJean Boussier2015-08-101-2/+11
|
* Add `:nodoc:` for internal testing methods [ci skip]Robin Dupret2015-07-281-2/+2
|
* match a expected value with message of `assert_equal` in AJ helper methodsyuuji.yaginuma2015-05-011-2/+2
|
* `ActiveJob::Base#queue_adapter` is now a `class_attribute`Tamir Duberstein2015-03-111-3/+15
| | | | | | This allows different `queue_adapters` to be used in each `ActiveJob` class heirarchy. Previously, all subclasses used a single global queue adapter.
* `ActiveJob::QueueAdapters::*` are no longer singletonsTamir Duberstein2015-03-111-3/+0
|
* Fix leaky `only: …` option for Active Job assertionsJeremy Kemper2015-03-061-9/+15
| | | | | | | The filter was set on the pseudo-global TestAdapter but not restored to its original value. See e818f65770fe115ab1cc7fbacc0e7e94d92af6a4
* `ActiveJob::QueueAdapters::TestAdapter` is now a singletonTamir Duberstein2015-02-231-2/+4
| | | | | | | | | Since `ActiveJob::TestHelper` globally sets `ActiveJob::Base.queue_adapter` on setup, there is no benefit in instantiating a new `TestAdapter` per tests. The original rationale was to allow parallel tests to run without interference, but since they'd all mutate the global `ActiveJob::Base.queue_adapter`, that was never realized.
* Add an `:only` option to `perform_enqueued_jobs` to filter jobs based onMichael Ryan2015-02-061-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type. This allows specific jobs to be tested, while preventing others from being performed unnecessarily. Example: def test_hello_job assert_performed_jobs 1, only: HelloJob do HelloJob.perform_later('jeremy') LoggingJob.perform_later end end An array may also be specified, to support testing multiple jobs. Example: def test_hello_and_logging_jobs assert_nothing_raised do assert_performed_jobs 2, only: [HelloJob, LoggingJob] do HelloJob.perform_later('jeremy') LoggingJob.perform_later('stewie') RescueJob.perform_later('david') end end end Fixes #18802. Trim space and document :only option.
* Fix ActiveJob assertions with a GlobalID object argumentRichard Manyanza2015-01-231-2/+12
|