aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/test_helper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Ability to test activejobs with relative delayVlado Cingel2019-07-261-1/+2
| | | | | | | | | | `assert_enqueued_with` and `assert_performed_with` were not able to properly test jobs with relative delay. `:at` option was asserted for equality and test will always fail cause small fraction of time will pass between job call and assertion. This commit fixes that by droping microseconds from `:at` argument assertions.
* Add Active Job release notes [ci skip] (#35872)प्रथमेश Sonpatki2019-04-051-2/+2
|
* Drop microseconds in job argument assertionsGannon McGibbon2019-03-221-0/+14
|
* Use native `Array#append`, `Array#prepend`, `Hash#transform_keys`, and ↵Ryuta Kamizono2018-12-201-1/+0
| | | | | | | | | | `Hash#transform_keys!` Since Rails 6 requires Ruby 2.5. https://github.com/ruby/ruby/blob/ruby_2_5/NEWS Follow up #34754.
* Allow all ActiveJob assertion helper to accept Proc in their `only` kw:Edouard CHIN2018-11-211-2/+32
| | | | | | | | - That feature is useful to enqueue or assert that jobs got enqueued or performed based on dynamic conditions. We will be able to leverage that feature to fix all ActionMailer assertion helper issue when a Mailer define a custom delivery job (see next commit).
* Merge pull request #34204 from XrXr/aj-test-helper-argsRafael França2018-10-241-3/+3
|\ | | | | Include deserialized arguments in jobs returned by AJ test helpers
| * Include deserialized arguments in jobs returned by AJ test helpersAlan Wu2018-10-121-3/+3
| | | | | | | | | | | | | | | | `assert_enqueued_with` and `assert_performed_with` return a instantiated instance of the matching job for further assertion (#21010). Before this commit the `arguments` method on the returned instance returns a serialized version of the arguments.
* | Clarify docs of `ActiveJob::TestHelper` [ci skip]bogdanvlviv2018-10-161-3/+3
|/ | | | | | | I found a few sentences that should be updated as well. See https://github.com/rails/rails/pull/33571#discussion_r209435886 Follow up #33571
* Documentation clarity in ActiveJob::TestHelper [ci skip] (#33571)Mohit Natoo2018-09-281-8/+8
| | | | | | | * Documentation clarity in ActiveJob::TestHelper [ci skip] * Documentation for options [Mohit Natoo + Rafael Mendonça França]
* Add a way to check for subset of arguments when performing jobs:Edouard CHIN2018-09-261-2/+48
| | | | | | | | | | | | - When calling `assert_performed_with`/`assert_enqueued_with`, the +args+ needs to match exactly what the job get passed. Some jobs can have lot of arguments, or even a simple hash argument has many key. This is not convenient to test as most tests doesn't need to check if the arguments matches perfectly. This PR make it possible to only check if a subset of arguments were passed to the job.
* Fix "warning: shadowing outer local variable - job"yuuji.yaginuma2018-09-221-2/+2
|
* Make `assert_<enqueued|performed>_with()` compare hashes ignoring order of keysSharang Dashputre2018-09-211-9/+16
| | | | The test helpers now treat `{ a: 1, b: 2 }` and `{ b: 2, a: 1 }` as equals
* 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`