diff options
Diffstat (limited to 'activejob/test/cases')
-rw-r--r-- | activejob/test/cases/argument_serialization_test.rb | 84 | ||||
-rw-r--r-- | activejob/test/cases/callbacks_test.rb | 5 | ||||
-rw-r--r-- | activejob/test/cases/job_serialization_test.rb | 2 | ||||
-rw-r--r-- | activejob/test/cases/logging_test.rb | 41 | ||||
-rw-r--r-- | activejob/test/cases/parameters_test.rb | 77 | ||||
-rw-r--r-- | activejob/test/cases/queue_naming_test.rb | 37 | ||||
-rw-r--r-- | activejob/test/cases/queuing_test.rb | 14 | ||||
-rw-r--r-- | activejob/test/cases/rescue_test.rb | 12 | ||||
-rw-r--r-- | activejob/test/cases/test_helper_test.rb | 70 |
9 files changed, 192 insertions, 150 deletions
diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb new file mode 100644 index 0000000000..dbe36fc572 --- /dev/null +++ b/activejob/test/cases/argument_serialization_test.rb @@ -0,0 +1,84 @@ +require 'helper' +require 'active_job/arguments' +require 'models/person' +require 'active_support/core_ext/hash/indifferent_access' + +class ArgumentSerializationTest < ActiveSupport::TestCase + setup do + @person = Person.find('5') + end + + [ nil, 1, 1.0, 1_000_000_000_000_000_000_000, + 'a', true, false, + [ 1, 'a' ], + { 'a' => 1 } + ].each do |arg| + test "serializes #{arg.class} verbatim" do + assert_arguments_unchanged arg + end + end + + [ :a, Object.new, self, Person.find('5').to_gid ].each do |arg| + test "does not serialize #{arg.class}" do + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ arg ] + end + + assert_raises ActiveJob::DeserializationError do + ActiveJob::Arguments.deserialize [ arg ] + end + end + end + + test 'should convert records to Global IDs' do + assert_arguments_roundtrip [@person], ['_aj_globalid' => @person.to_gid.to_s] + end + + test 'should dive deep into arrays and hashes' do + assert_arguments_roundtrip [3, [@person]], [3, ['_aj_globalid' => @person.to_gid.to_s]] + assert_arguments_roundtrip [{ 'a' => @person }], [{ 'a' => { '_aj_globalid' => @person.to_gid.to_s }}.with_indifferent_access] + end + + test 'should stringify symbol hash keys' do + assert_equal [ 'a' => 1 ], ActiveJob::Arguments.serialize([ a: 1 ]) + end + + test 'should disallow non-string/symbol hash keys' do + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ { 1 => 2 } ] + end + + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ { :a => [{ 2 => 3 }] } ] + end + + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ '_aj_globalid' => 1 ] + end + + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ :_aj_globalid => 1 ] + end + end + + test 'should not allow non-primitive objects' do + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [Object.new] + end + + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [1, [Object.new]] + end + end + + private + def assert_arguments_unchanged(*args) + assert_arguments_roundtrip args, args + end + + def assert_arguments_roundtrip(args, expected_serialized_args) + serialized = ActiveJob::Arguments.serialize(args) + assert_equal expected_serialized_args, serialized + assert_equal args, ActiveJob::Arguments.deserialize(serialized) + end +end diff --git a/activejob/test/cases/callbacks_test.rb b/activejob/test/cases/callbacks_test.rb index 9a0657ee89..9af2380767 100644 --- a/activejob/test/cases/callbacks_test.rb +++ b/activejob/test/cases/callbacks_test.rb @@ -5,7 +5,8 @@ require 'active_support/core_ext/object/inclusion' class CallbacksTest < ActiveSupport::TestCase test 'perform callbacks' do - performed_callback_job = CallbackJob.new.tap { |j| j.execute("A-JOB-ID") } + performed_callback_job = CallbackJob.new("A-JOB-ID") + performed_callback_job.perform_now assert "CallbackJob ran before_perform".in? performed_callback_job.history assert "CallbackJob ran after_perform".in? performed_callback_job.history assert "CallbackJob ran around_perform_start".in? performed_callback_job.history @@ -13,7 +14,7 @@ class CallbacksTest < ActiveSupport::TestCase end test 'enqueue callbacks' do - enqueued_callback_job = CallbackJob.enqueue + enqueued_callback_job = CallbackJob.perform_later assert "CallbackJob ran before_enqueue".in? enqueued_callback_job.history assert "CallbackJob ran after_enqueue".in? enqueued_callback_job.history assert "CallbackJob ran around_enqueue_start".in? enqueued_callback_job.history diff --git a/activejob/test/cases/job_serialization_test.rb b/activejob/test/cases/job_serialization_test.rb index fc1b77744c..db22783030 100644 --- a/activejob/test/cases/job_serialization_test.rb +++ b/activejob/test/cases/job_serialization_test.rb @@ -9,7 +9,7 @@ class JobSerializationTest < ActiveSupport::TestCase end test 'serialize job with gid' do - GidJob.enqueue @person + GidJob.perform_later @person assert_equal "Person with ID: 5", JobBuffer.last_value end end diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index 888c183a0b..9c56ee08b6 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -42,34 +42,43 @@ class AdapterTest < ActiveSupport::TestCase def test_uses_active_job_as_tag - HelloJob.enqueue "Cristian" + HelloJob.perform_later "Cristian" assert_match(/\[ActiveJob\]/, @logger.messages) end + def test_uses_job_name_as_tag + LoggingJob.perform_later "Dummy" + assert_match(/\[LoggingJob\]/, @logger.messages) + end + + def test_uses_job_id_as_tag + LoggingJob.perform_later "Dummy" + assert_match(/\[LOGGING-JOB-ID\]/, @logger.messages) + end + + def test_logs_correct_queue_name + original_queue_name = LoggingJob.queue_name + LoggingJob.queue_as :php_jobs + LoggingJob.perform_later("Dummy") + assert_match(/to .*?\(php_jobs\).*/, @logger.messages) + ensure + LoggingJob.queue_name = original_queue_name + end + def test_enqueue_job_logging - HelloJob.enqueue "Cristian" + HelloJob.perform_later "Cristian" assert_match(/Enqueued HelloJob \(Job ID: .*?\) to .*?:.*Cristian/, @logger.messages) end def test_perform_job_logging - LoggingJob.enqueue "Dummy" + LoggingJob.perform_later "Dummy" assert_match(/Performing LoggingJob from .*? with arguments:.*Dummy/, @logger.messages) assert_match(/Dummy, here is it: Dummy/, @logger.messages) assert_match(/Performed LoggingJob from .*? in .*ms/, @logger.messages) end - def test_perform_uses_job_name_job_logging - LoggingJob.enqueue "Dummy" - assert_match(/\[LoggingJob\]/, @logger.messages) - end - - def test_perform_uses_job_id_job_logging - LoggingJob.enqueue "Dummy" - assert_match(/\[LOGGING-JOB-ID\]/, @logger.messages) - end - def test_perform_nested_jobs_logging - NestedJob.enqueue + NestedJob.perform_later assert_match(/\[LoggingJob\] \[.*?\]/, @logger.messages) assert_match(/\[ActiveJob\] Enqueued NestedJob \(Job ID: .*\) to/, @logger.messages) assert_match(/\[ActiveJob\] \[NestedJob\] \[NESTED-JOB-ID\] Performing NestedJob from/, @logger.messages) @@ -81,14 +90,14 @@ class AdapterTest < ActiveSupport::TestCase end def test_enqueue_at_job_logging - HelloJob.enqueue_at 1, "Cristian" + HelloJob.set(wait_until: 24.hours.from_now).perform_later "Cristian" assert_match(/Enqueued HelloJob \(Job ID: .*\) to .*? at.*Cristian/, @logger.messages) rescue NotImplementedError skip end def test_enqueue_in_job_logging - HelloJob.enqueue_in 2, "Cristian" + HelloJob.set(wait: 2.seconds).perform_later "Cristian" assert_match(/Enqueued HelloJob \(Job ID: .*\) to .*? at.*Cristian/, @logger.messages) rescue NotImplementedError skip diff --git a/activejob/test/cases/parameters_test.rb b/activejob/test/cases/parameters_test.rb deleted file mode 100644 index 78853c51e1..0000000000 --- a/activejob/test/cases/parameters_test.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'helper' -require 'active_job/arguments' -require 'models/person' -require 'active_support/core_ext/hash/indifferent_access' - -class ParameterSerializationTest < ActiveSupport::TestCase - test 'should make no change to regular values' do - assert_equal [ 1, "something" ], ActiveJob::Arguments.serialize([ 1, "something" ]) - end - - test 'should not allow complex objects' do - assert_equal [ nil ], ActiveJob::Arguments.serialize([ nil ]) - assert_equal [ 1 ], ActiveJob::Arguments.serialize([ 1 ]) - assert_equal [ 1.0 ], ActiveJob::Arguments.serialize([ 1.0 ]) - assert_equal [ 'a' ], ActiveJob::Arguments.serialize([ 'a' ]) - assert_equal [ true ], ActiveJob::Arguments.serialize([ true ]) - assert_equal [ false ], ActiveJob::Arguments.serialize([ false ]) - assert_equal [ { "a" => 1, "b" => 2 } ], ActiveJob::Arguments.serialize([ { a: 1, "b" => 2 } ]) - assert_equal [ [ 1 ] ], ActiveJob::Arguments.serialize([ [ 1 ] ]) - assert_equal [ 1_000_000_000_000_000_000_000 ], ActiveJob::Arguments.serialize([ 1_000_000_000_000_000_000_000 ]) - - err = assert_raises ActiveJob::SerializationError do - ActiveJob::Arguments.serialize([ 1, self ]) - end - assert_equal "Unsupported argument type: #{self.class.name}", err.message - end - - test 'should dive deep into arrays or hashes' do - assert_equal [ { "a" => Person.find(5).gid.to_s }.with_indifferent_access ], ActiveJob::Arguments.serialize([ { a: Person.find(5) } ]) - assert_equal [ [ Person.find(5).gid.to_s ] ], ActiveJob::Arguments.serialize([ [ Person.find(5) ] ]) - end - - test 'should dive deep into arrays or hashes and raise exception on complex objects' do - err = assert_raises ActiveJob::SerializationError do - ActiveJob::Arguments.serialize([ 1, [self] ]) - end - assert_equal "Unsupported argument type: #{self.class.name}", err.message - end - - test 'shoud dive deep into hashes and allow raise exception on not string/symbol keys' do - err = assert_raises ActiveJob::SerializationError do - ActiveJob::Arguments.serialize([ [ { 1 => 2 } ] ]) - end - assert_equal "Unsupported hash key type: Fixnum", err.message - end - - test 'should serialize records with global id' do - assert_equal [ Person.find(5).gid.to_s ], ActiveJob::Arguments.serialize([ Person.find(5) ]) - end - - test 'should serialize values and records together' do - assert_equal [ 3, Person.find(5).gid.to_s ], ActiveJob::Arguments.serialize([ 3, Person.find(5) ]) - end -end - -class ParameterDeserializationTest < ActiveSupport::TestCase - test 'should make no change to regular values' do - assert_equal [ 1, "something" ], ActiveJob::Arguments.deserialize([ 1, "something" ]) - end - - test 'should deserialize records with global id' do - assert_equal [ Person.find(5) ], ActiveJob::Arguments.deserialize([ Person.find(5).gid ]) - end - - test 'should serialize values and records together' do - assert_equal [ 3, Person.find(5) ], ActiveJob::Arguments.deserialize([ 3, Person.find(5).gid ]) - end - - test 'should dive deep when deserialising arrays' do - assert_equal [ [ 3, Person.find(5) ] ], ActiveJob::Arguments.deserialize([ [ 3, Person.find(5).gid ] ]) - end - - test 'should dive deep when deserialising hashes' do - assert_equal [ { "5" => Person.find(5) } ], ActiveJob::Arguments.deserialize([ { "5" => Person.find(5).gid } ]) - end - -end diff --git a/activejob/test/cases/queue_naming_test.rb b/activejob/test/cases/queue_naming_test.rb index fdfd1afceb..4052477543 100644 --- a/activejob/test/cases/queue_naming_test.rb +++ b/activejob/test/cases/queue_naming_test.rb @@ -8,20 +8,38 @@ class QueueNamingTest < ActiveSupport::TestCase assert_equal "default", HelloJob.queue_name end - test 'name appended in job' do + test 'uses given queue name job' do begin + original_queue_name = HelloJob.queue_name HelloJob.queue_as :greetings - LoggingJob.queue_as :bookkeeping + assert_equal "greetings", HelloJob.new.queue_name + ensure + HelloJob.queue_name = original_queue_name + end + end - assert_equal "default", NestedJob.queue_name - assert_equal "greetings", HelloJob.queue_name - assert_equal "bookkeeping", LoggingJob.queue_name + test 'evals block given to queue_as to determine queue' do + begin + original_queue_name = HelloJob.queue_name + HelloJob.queue_as { :another } + assert_equal "another", HelloJob.new.queue_name ensure - HelloJob.queue_name = LoggingJob.queue_name = ActiveJob::Base.default_queue_name + HelloJob.queue_name = original_queue_name end end - test 'should prefix the queue name' do + test 'can use arguments to determine queue_name in queue_as block' do + begin + original_queue_name = HelloJob.queue_name + HelloJob.queue_as { self.arguments.first=='1' ? :one : :two } + assert_equal "one", HelloJob.new('1').queue_name + assert_equal "two", HelloJob.new('3').queue_name + ensure + HelloJob.queue_name = original_queue_name + end + end + + test 'queu_name_prefix prepended to the queue name' do begin original_queue_name_prefix = ActiveJob::Base.queue_name_prefix original_queue_name = HelloJob.queue_name @@ -35,4 +53,9 @@ class QueueNamingTest < ActiveSupport::TestCase end end + test 'uses queue passed to #set' do + job = HelloJob.set(queue: :some_queue).perform_later + assert_equal "some_queue", job.queue_name + end + end diff --git a/activejob/test/cases/queuing_test.rb b/activejob/test/cases/queuing_test.rb index f020316d7e..0eeabbf693 100644 --- a/activejob/test/cases/queuing_test.rb +++ b/activejob/test/cases/queuing_test.rb @@ -9,18 +9,18 @@ class QueuingTest < ActiveSupport::TestCase end test 'run queued job' do - HelloJob.enqueue + HelloJob.perform_later assert_equal "David says hello", JobBuffer.last_value end test 'run queued job with arguments' do - HelloJob.enqueue "Jamie" + HelloJob.perform_later "Jamie" assert_equal "Jamie says hello", JobBuffer.last_value end test 'run queued job later' do begin - result = HelloJob.enqueue_at 1.second.ago, "Jamie" + result = HelloJob.set(wait_until: 1.second.ago).perform_later "Jamie" assert result rescue NotImplementedError skip @@ -28,15 +28,15 @@ class QueuingTest < ActiveSupport::TestCase end test 'job returned by enqueue has the arguments available' do - job = HelloJob.enqueue "Jamie" + job = HelloJob.perform_later "Jamie" assert_equal [ "Jamie" ], job.arguments end - test 'job returned by enqueue_at has the timestamp available' do + test 'job returned by perform_at has the timestamp available' do begin - job = HelloJob.enqueue_at Time.utc(2014, 1, 1) - assert_equal Time.utc(2014, 1, 1), job.enqueued_at + job = HelloJob.set(wait_until: Time.utc(2014, 1, 1)).perform_later + assert_equal Time.utc(2014, 1, 1).to_f, job.scheduled_at rescue NotImplementedError skip end diff --git a/activejob/test/cases/rescue_test.rb b/activejob/test/cases/rescue_test.rb index 3af147383e..1b6c2e9fac 100644 --- a/activejob/test/cases/rescue_test.rb +++ b/activejob/test/cases/rescue_test.rb @@ -10,27 +10,27 @@ class RescueTest < ActiveSupport::TestCase end test 'rescue perform exception with retry' do - job = RescueJob.new - job.execute(SecureRandom.uuid, "david") + job = RescueJob.new("david") + job.perform_now assert_equal [ "rescued from ArgumentError", "performed beautifully" ], JobBuffer.values end test 'let through unhandled perform exception' do - job = RescueJob.new + job = RescueJob.new("other") assert_raises(RescueJob::OtherError) do - job.execute(SecureRandom.uuid, "other") + job.perform_now end end test 'rescue from deserialization errors' do - RescueJob.enqueue Person.new(404) + RescueJob.perform_later Person.new(404) assert_includes JobBuffer.values, 'rescued from DeserializationError' assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound' assert_not_includes JobBuffer.values, 'performed beautifully' end test "should not wrap DeserializationError in DeserializationError" do - RescueJob.enqueue [Person.new(404)] + RescueJob.perform_later [Person.new(404)] assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound' end end diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index 240aa23ce3..71c505a65f 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -11,7 +11,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs assert_nothing_raised do assert_enqueued_jobs 1 do - HelloJob.enqueue('david') + HelloJob.perform_later('david') end end end @@ -19,27 +19,27 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_repeated_enqueued_jobs_calls assert_nothing_raised do assert_enqueued_jobs 1 do - HelloJob.enqueue('abdelkader') + HelloJob.perform_later('abdelkader') end end assert_nothing_raised do assert_enqueued_jobs 2 do - HelloJob.enqueue('sean') - HelloJob.enqueue('yves') + HelloJob.perform_later('sean') + HelloJob.perform_later('yves') end end end def test_assert_enqueued_jobs_with_no_block assert_nothing_raised do - HelloJob.enqueue('rafael') + HelloJob.perform_later('rafael') assert_enqueued_jobs 1 end assert_nothing_raised do - HelloJob.enqueue('aaron') - HelloJob.enqueue('matthew') + HelloJob.perform_later('aaron') + HelloJob.perform_later('matthew') assert_enqueued_jobs 3 end end @@ -48,7 +48,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_nothing_raised do assert_no_enqueued_jobs do # Scheduled jobs are being performed in this context - HelloJob.enqueue_at(Date.tomorrow.noon, 'godfrey') + HelloJob.set(wait_until: Date.tomorrow.noon).perform_later('godfrey') end end end @@ -56,7 +56,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 2 do - HelloJob.enqueue('xavier') + HelloJob.perform_later('xavier') end end @@ -66,8 +66,8 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_jobs_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1 do - HelloJob.enqueue('cristian') - HelloJob.enqueue('guillermo') + HelloJob.perform_later('cristian') + HelloJob.perform_later('guillermo') end end @@ -77,7 +77,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_no_enqueued_jobs_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs do - HelloJob.enqueue('jeremy') + HelloJob.perform_later('jeremy') end end @@ -86,28 +86,30 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_job assert_enqueued_with(job: LoggingJob, queue: 'default') do - NestedJob.enqueue_at(Date.tomorrow.noon) + NestedJob.set(wait_until: Date.tomorrow.noon).perform_later end end def test_assert_enqueued_job_failure assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_with(job: LoggingJob, queue: 'default') do - NestedJob.enqueue + NestedJob.perform_later end end - assert_raise ActiveSupport::TestCase::Assertion do + error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_with(job: NestedJob, queue: 'low') do - NestedJob.enqueue + NestedJob.perform_later end end + + assert_equal 'No enqueued job found with {:job=>NestedJob, :queue=>"low"}', error.message end def test_assert_enqueued_job_args assert_raise ArgumentError do assert_enqueued_with(class: LoggingJob) do - NestedJob.enqueue_at(Date.tomorrow.noon) + NestedJob.set(wait_until: Date.tomorrow.noon).perform_later end end end @@ -119,7 +121,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs assert_nothing_raised do assert_performed_jobs 1 do - HelloJob.enqueue('david') + HelloJob.perform_later('david') end end end @@ -127,27 +129,27 @@ class PerformedJobsTest < ActiveJob::TestCase def test_repeated_performed_jobs_calls assert_nothing_raised do assert_performed_jobs 1 do - HelloJob.enqueue('abdelkader') + HelloJob.perform_later('abdelkader') end end assert_nothing_raised do assert_performed_jobs 2 do - HelloJob.enqueue('sean') - HelloJob.enqueue('yves') + HelloJob.perform_later('sean') + HelloJob.perform_later('yves') end end end def test_assert_performed_jobs_with_no_block assert_nothing_raised do - HelloJob.enqueue('rafael') + HelloJob.perform_later('rafael') assert_performed_jobs 1 end assert_nothing_raised do - HelloJob.enqueue('aaron') - HelloJob.enqueue('matthew') + HelloJob.perform_later('aaron') + HelloJob.perform_later('matthew') assert_performed_jobs 3 end end @@ -156,7 +158,7 @@ class PerformedJobsTest < ActiveJob::TestCase assert_nothing_raised do assert_no_performed_jobs do # Scheduled jobs are being enqueued in this context - HelloJob.enqueue_at(Date.tomorrow.noon, 'godfrey') + HelloJob.set(wait_until: Date.tomorrow.noon).perform_later('godfrey') end end end @@ -164,7 +166,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 2 do - HelloJob.enqueue('xavier') + HelloJob.perform_later('xavier') end end @@ -174,8 +176,8 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_jobs_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 1 do - HelloJob.enqueue('cristian') - HelloJob.enqueue('guillermo') + HelloJob.perform_later('cristian') + HelloJob.perform_later('guillermo') end end @@ -185,7 +187,7 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_no_performed_jobs_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_performed_jobs do - HelloJob.enqueue('jeremy') + HelloJob.perform_later('jeremy') end end @@ -194,20 +196,20 @@ class PerformedJobsTest < ActiveJob::TestCase def test_assert_performed_job assert_performed_with(job: NestedJob, queue: 'default') do - NestedJob.enqueue + NestedJob.perform_later end end def test_assert_performed_job_failure assert_raise ActiveSupport::TestCase::Assertion do - assert_performed_with(job: LoggingJob, queue: 'default') do - NestedJob.enqueue_at(Date.tomorrow.noon) + assert_performed_with(job: LoggingJob, at: Date.tomorrow.noon, queue: 'default') do + NestedJob.set(wait_until: Date.tomorrow.noon).perform_later end end assert_raise ActiveSupport::TestCase::Assertion do - assert_performed_with(job: NestedJob, queue: 'low') do - NestedJob.enqueue_at(Date.tomorrow.noon) + assert_performed_with(job: NestedJob, at: Date.tomorrow.noon, queue: 'low') do + NestedJob.set(queue: 'low', wait_until: Date.tomorrow.noon).perform_later end end end |