1
0
Fork 0
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:
bogdanvlviv 2018-08-16 22:48:18 +03:00
parent b7beb5d4e5
commit b8576425ee
No known key found for this signature in database
GPG key ID: E4ACD76A6DB6DFDD

View file

@ -118,13 +118,17 @@ module ActiveJob
def assert_enqueued_jobs(number, only: nil, except: nil, queue: nil)
if block_given?
original_count = enqueued_jobs_with(only: only, except: except, queue: queue)
yield
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
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
assert_equal number, actual_count, "#{number} jobs expected, but #{actual_count} were enqueued"
end
# Asserts that no jobs have been enqueued.