aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job
diff options
context:
space:
mode:
authorWojciech Wnętrzak <w.wnetrzak@gmail.com>2015-10-03 15:18:25 +0200
committerWojciech Wnętrzak <w.wnetrzak@gmail.com>2015-10-03 15:23:05 +0200
commit6e0254e8d3c1dce532208bc868427d17aabbce5a (patch)
tree5844e3cb40500c2867c0c3fbc016db27eaf466d7 /activejob/lib/active_job
parent55ac94cec45328657c579024bb835fe18bb2d32b (diff)
downloadrails-6e0254e8d3c1dce532208bc868427d17aabbce5a.tar.gz
rails-6e0254e8d3c1dce532208bc868427d17aabbce5a.tar.bz2
rails-6e0254e8d3c1dce532208bc868427d17aabbce5a.zip
Fixed serializing `:at` option for `assert_enqueued_with` and `assert_performed_with`
Diffstat (limited to 'activejob/lib/active_job')
-rw-r--r--activejob/lib/active_job/test_helper.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb
index 666e984fe0..de79de59f8 100644
--- a/activejob/lib/active_job/test_helper.rb
+++ b/activejob/lib/active_job/test_helper.rb
@@ -226,6 +226,10 @@ module ActiveJob
# assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') do
# MyJob.perform_later(1,2,3)
# end
+ #
+ # assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon) do
+ # MyJob.set(wait_until: Date.tomorrow.noon).perform_later
+ # end
# end
def assert_enqueued_with(args = {}, &_block)
original_enqueued_jobs = enqueued_jobs.dup
@@ -248,6 +252,10 @@ module ActiveJob
# assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high') do
# MyJob.perform_later(1,2,3)
# end
+ #
+ # assert_performed_with(job: MyJob, at: Date.tomorrow.noon) do
+ # MyJob.set(wait_until: Date.tomorrow.noon).perform_later
+ # end
# end
def assert_performed_with(args = {}, &_block)
original_performed_jobs = performed_jobs.dup
@@ -307,11 +315,10 @@ module ActiveJob
end
def serialize_args_for_assertion(args) # :nodoc:
- serialized_args = args.dup
- if job_args = serialized_args.delete(:args)
- serialized_args[:args] = ActiveJob::Arguments.serialize(job_args)
+ args.dup.tap do |serialized_args|
+ serialized_args[:args] = ActiveJob::Arguments.serialize(serialized_args[:args]) if serialized_args[:args]
+ serialized_args[:at] = serialized_args[:at].to_f if serialized_args[:at]
end
- serialized_args
end
def instantiate_job(payload) # :nodoc: