aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2018-08-16 22:48:18 +0300
committerbogdanvlviv <bogdanvlviv@gmail.com>2018-08-20 13:05:29 +0300
commitb8576425eeee2eaa82c5acb08227f5bb2dcd07b7 (patch)
tree613c126289e90ce7c68cc3b0be57ae0e99591d52 /activejob
parentb7beb5d4e5a5f642d172002723ef269d0c6a0bfd (diff)
downloadrails-b8576425eeee2eaa82c5acb08227f5bb2dcd07b7.tar.gz
rails-b8576425eeee2eaa82c5acb08227f5bb2dcd07b7.tar.bz2
rails-b8576425eeee2eaa82c5acb08227f5bb2dcd07b7.zip
DRY in `assert_enqueued_jobs`
Diffstat (limited to 'activejob')
-rw-r--r--activejob/lib/active_job/test_helper.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb
index dbf9bfb3a4..bb9e3e6ca4 100644
--- a/activejob/lib/active_job/test_helper.rb
+++ b/activejob/lib/active_job/test_helper.rb
@@ -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.