diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-08-16 19:49:14 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-08-20 13:05:29 +0300 |
commit | de4420da44ecce68a6b7607b828c69959a5f738e (patch) | |
tree | 0a6215e205b9e00486376c7aebc068cd2670cfe1 /activejob/lib/active_job | |
parent | d50fb21e4d7a526de3b0edb9bb5032d4be6175ae (diff) | |
download | rails-de4420da44ecce68a6b7607b828c69959a5f738e.tar.gz rails-de4420da44ecce68a6b7607b828c69959a5f738e.tar.bz2 rails-de4420da44ecce68a6b7607b828c69959a5f738e.zip |
Allow `:queue` option to `assert_no_performed_jobs`.
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
```
Diffstat (limited to 'activejob/lib/active_job')
-rw-r--r-- | activejob/lib/active_job/test_helper.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index 3be74e504b..4dae1a9969 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -297,11 +297,20 @@ module ActiveJob # end # end # + # If the +:queue+ option is specified, + # then only the job(s) enqueued to a specific queue will not be performed. + # + # 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 + # # Note: This assertion is simply a shortcut for: # # assert_performed_jobs 0, &block - def assert_no_performed_jobs(only: nil, except: nil, &block) - assert_performed_jobs 0, only: only, except: except, &block + def assert_no_performed_jobs(only: nil, except: nil, queue: nil, &block) + assert_performed_jobs 0, only: only, except: except, queue: queue, &block end # Asserts that the job has been enqueued with the given arguments. |