mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
DRY in assert_enqueued_jobs
This commit is contained in:
parent
b7beb5d4e5
commit
b8576425ee
1 changed files with 6 additions and 2 deletions
|
@ -118,13 +118,17 @@ module ActiveJob
|
||||||
def assert_enqueued_jobs(number, only: nil, except: nil, queue: nil)
|
def assert_enqueued_jobs(number, only: nil, except: nil, queue: nil)
|
||||||
if block_given?
|
if block_given?
|
||||||
original_count = enqueued_jobs_with(only: only, except: except, queue: queue)
|
original_count = enqueued_jobs_with(only: only, except: except, queue: queue)
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
new_count = enqueued_jobs_with(only: only, except: except, queue: queue)
|
new_count = enqueued_jobs_with(only: only, except: except, queue: queue)
|
||||||
assert_equal number, new_count - original_count, "#{number} jobs expected, but #{new_count - original_count} were enqueued"
|
|
||||||
|
actual_count = new_count - original_count
|
||||||
else
|
else
|
||||||
actual_count = enqueued_jobs_with(only: only, except: except, queue: queue)
|
actual_count = enqueued_jobs_with(only: only, except: except, queue: queue)
|
||||||
assert_equal number, actual_count, "#{number} jobs expected, but #{actual_count} were enqueued"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_equal number, actual_count, "#{number} jobs expected, but #{actual_count} were enqueued"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Asserts that no jobs have been enqueued.
|
# Asserts that no jobs have been enqueued.
|
||||||
|
|
Loading…
Reference in a new issue