class EnqueuedJobsTest
Public Instance Methods
test_assert_enqueued_job()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 392 def test_assert_enqueued_job assert_enqueued_with(job: LoggingJob, queue: "default") do LoggingJob.set(wait_until: Date.tomorrow.noon).perform_later end end
test_assert_enqueued_job_args()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 425 def test_assert_enqueued_job_args assert_raise ArgumentError do assert_enqueued_with(class: LoggingJob) do NestedJob.set(wait_until: Date.tomorrow.noon).perform_later end end end
test_assert_enqueued_job_does_not_change_jobs_count()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 458 def test_assert_enqueued_job_does_not_change_jobs_count HelloJob.perform_later assert_enqueued_with(job: HelloJob) do HelloJob.perform_later end assert_equal 2, queue_adapter.enqueued_jobs.count end
test_assert_enqueued_job_failure()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 409 def test_assert_enqueued_job_failure assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_with(job: LoggingJob, queue: "default") do NestedJob.perform_later end end error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_with(job: NestedJob, queue: "low") do NestedJob.perform_later end end assert_equal 'No enqueued job found with {:job=>NestedJob, :queue=>"low"}', error.message end
test_assert_enqueued_job_failure_with_global_id_args()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 446 def test_assert_enqueued_job_failure_with_global_id_args ricardo = Person.new(9) wilma = Person.new(11) error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_with(job: HelloJob, args: [wilma]) do HelloJob.perform_later(ricardo) end end assert_equal "No enqueued job found with {:job=>HelloJob, :args=>[#{wilma.inspect}]}", error.message end
test_assert_enqueued_job_returns()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 398 def test_assert_enqueued_job_returns job = assert_enqueued_with(job: LoggingJob) do LoggingJob.set(wait_until: 5.minutes.from_now).perform_later(1, 2, 3) end assert_instance_of LoggingJob, job assert_in_delta 5.minutes.from_now, job.scheduled_at, 1 assert_equal "default", job.queue_name assert_equal [1, 2, 3], job.arguments end
test_assert_enqueued_job_with_at_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 433 def test_assert_enqueued_job_with_at_option assert_enqueued_with(job: HelloJob, at: Date.tomorrow.noon) do HelloJob.set(wait_until: Date.tomorrow.noon).perform_later end end
test_assert_enqueued_job_with_global_id_args()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 439 def test_assert_enqueued_job_with_global_id_args ricardo = Person.new(9) assert_enqueued_with(job: HelloJob, args: [ricardo]) do HelloJob.perform_later(ricardo) end end
test_assert_enqueued_jobs()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 14 def test_assert_enqueued_jobs assert_nothing_raised do assert_enqueued_jobs 1 do HelloJob.perform_later("david") end end end
test_assert_enqueued_jobs_message()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 37 def test_assert_enqueued_jobs_message HelloJob.perform_later("sean") e = assert_raises Minitest::Assertion do assert_enqueued_jobs 2 do HelloJob.perform_later("sean") end end assert_match "Expected: 2", e.message assert_match "Actual: 1", e.message end
test_assert_enqueued_jobs_too_few_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 75 def test_assert_enqueued_jobs_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 2 do HelloJob.perform_later("xavier") end end assert_match(/2 .* but 1/, error.message) end
test_assert_enqueued_jobs_too_many_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 85 def test_assert_enqueued_jobs_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1 do HelloJob.perform_later("cristian") HelloJob.perform_later("guillermo") end end assert_match(/1 .* but 2/, error.message) end
test_assert_enqueued_jobs_with_except_and_queue_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 148 def test_assert_enqueued_jobs_with_except_and_queue_option assert_nothing_raised do assert_enqueued_jobs 1, except: LoggingJob, queue: :some_queue do HelloJob.set(queue: :some_queue).perform_later HelloJob.set(queue: :other_queue).perform_later LoggingJob.perform_later end end end
test_assert_enqueued_jobs_with_except_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 116 def test_assert_enqueued_jobs_with_except_option assert_nothing_raised do assert_enqueued_jobs 1, except: LoggingJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later LoggingJob.perform_later end end end
test_assert_enqueued_jobs_with_except_option_and_none_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 191 def test_assert_enqueued_jobs_with_except_option_and_none_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1, except: LoggingJob do LoggingJob.perform_later end end assert_match(/1 .* but 0/, error.message) end
test_assert_enqueued_jobs_with_except_option_and_too_few_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 222 def test_assert_enqueued_jobs_with_except_option_and_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 5, except: LoggingJob do HelloJob.perform_later("jeremy") 4.times { LoggingJob.perform_later } end end assert_match(/5 .* but 1/, error.message) end
test_assert_enqueued_jobs_with_except_option_and_too_many_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 254 def test_assert_enqueued_jobs_with_except_option_and_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1, except: LoggingJob do 2.times { HelloJob.perform_later("jeremy") } end end assert_match(/1 .* but 2/, error.message) end
test_assert_enqueued_jobs_with_except_option_as_array()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 284 def test_assert_enqueued_jobs_with_except_option_as_array assert_nothing_raised do assert_enqueued_jobs 1, except: [HelloJob, LoggingJob] do HelloJob.perform_later("jeremy") LoggingJob.perform_later("stewie") RescueJob.perform_later("david") end end end
test_assert_enqueued_jobs_with_no_block()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 48 def test_assert_enqueued_jobs_with_no_block assert_nothing_raised do HelloJob.perform_later("rafael") assert_enqueued_jobs 1 end assert_nothing_raised do HelloJob.perform_later("aaron") HelloJob.perform_later("matthew") assert_enqueued_jobs 3 end end
test_assert_enqueued_jobs_with_only_and_except_and_queue_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 158 def test_assert_enqueued_jobs_with_only_and_except_and_queue_option error = assert_raise ArgumentError do assert_enqueued_jobs 1, only: HelloJob, except: HelloJob, queue: :some_queue do HelloJob.set(queue: :some_queue).perform_later HelloJob.set(queue: :other_queue).perform_later LoggingJob.perform_later end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_enqueued_jobs_with_only_and_except_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 126 def test_assert_enqueued_jobs_with_only_and_except_option error = assert_raise ArgumentError do assert_enqueued_jobs 1, only: HelloJob, except: HelloJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later LoggingJob.perform_later end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_enqueued_jobs_with_only_and_except_option_and_none_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 201 def test_assert_enqueued_jobs_with_only_and_except_option_and_none_sent error = assert_raise ArgumentError do assert_enqueued_jobs 1, only: HelloJob, except: HelloJob do LoggingJob.perform_later end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_enqueued_jobs_with_only_and_except_option_and_too_few_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 233 def test_assert_enqueued_jobs_with_only_and_except_option_and_too_few_sent error = assert_raise ArgumentError do assert_enqueued_jobs 5, only: HelloJob, except: HelloJob do HelloJob.perform_later("jeremy") 4.times { LoggingJob.perform_later } end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_enqueued_jobs_with_only_and_except_option_and_too_many_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 264 def test_assert_enqueued_jobs_with_only_and_except_option_and_too_many_sent error = assert_raise ArgumentError do assert_enqueued_jobs 1, only: HelloJob, except: HelloJob do 2.times { HelloJob.perform_later("jeremy") } end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_enqueued_jobs_with_only_and_except_option_as_array()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 294 def test_assert_enqueued_jobs_with_only_and_except_option_as_array error = assert_raise ArgumentError do assert_enqueued_jobs 2, only: [HelloJob, LoggingJob], except: [HelloJob, LoggingJob] do HelloJob.perform_later("jeremy") LoggingJob.perform_later("stewie") RescueJob.perform_later("david") end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_enqueued_jobs_with_only_and_queue_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 138 def test_assert_enqueued_jobs_with_only_and_queue_option assert_nothing_raised do assert_enqueued_jobs 1, only: HelloJob, queue: :some_queue do HelloJob.set(queue: :some_queue).perform_later HelloJob.set(queue: :other_queue).perform_later LoggingJob.perform_later end end end
test_assert_enqueued_jobs_with_only_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 106 def test_assert_enqueued_jobs_with_only_option assert_nothing_raised do assert_enqueued_jobs 1, only: HelloJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later LoggingJob.perform_later end end end
test_assert_enqueued_jobs_with_only_option_and_none_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 181 def test_assert_enqueued_jobs_with_only_option_and_none_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1, only: HelloJob do LoggingJob.perform_later end end assert_match(/1 .* but 0/, error.message) end
test_assert_enqueued_jobs_with_only_option_and_too_few_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 211 def test_assert_enqueued_jobs_with_only_option_and_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 5, only: HelloJob do HelloJob.perform_later("jeremy") 4.times { LoggingJob.perform_later } end end assert_match(/5 .* but 1/, error.message) end
test_assert_enqueued_jobs_with_only_option_and_too_many_sent()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 244 def test_assert_enqueued_jobs_with_only_option_and_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_jobs 1, only: HelloJob do 2.times { HelloJob.perform_later("jeremy") } end end assert_match(/1 .* but 2/, error.message) end
test_assert_enqueued_jobs_with_only_option_as_array()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 274 def test_assert_enqueued_jobs_with_only_option_as_array assert_nothing_raised do assert_enqueued_jobs 2, only: [HelloJob, LoggingJob] do HelloJob.perform_later("jeremy") LoggingJob.perform_later("stewie") RescueJob.perform_later("david") end end end
test_assert_enqueued_jobs_with_queue_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 170 def test_assert_enqueued_jobs_with_queue_option assert_nothing_raised do assert_enqueued_jobs 2, queue: :default do HelloJob.perform_later LoggingJob.perform_later HelloJob.set(queue: :other_queue).perform_later LoggingJob.set(queue: :other_queue).perform_later end end end
test_assert_no_enqueued_jobs()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 67 def test_assert_no_enqueued_jobs assert_nothing_raised do assert_no_enqueued_jobs do HelloJob.perform_now end end end
test_assert_no_enqueued_jobs_failure()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 96 def test_assert_no_enqueued_jobs_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs do HelloJob.perform_later("jeremy") end end assert_match(/0 .* but 1/, error.message) end
test_assert_no_enqueued_jobs_with_except_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 314 def test_assert_no_enqueued_jobs_with_except_option assert_nothing_raised do assert_no_enqueued_jobs except: LoggingJob do LoggingJob.perform_later end end end
test_assert_no_enqueued_jobs_with_except_option_as_array()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 373 def test_assert_no_enqueued_jobs_with_except_option_as_array assert_nothing_raised do assert_no_enqueued_jobs except: [HelloJob, RescueJob] do HelloJob.perform_later RescueJob.perform_later end end end
test_assert_no_enqueued_jobs_with_except_option_failure()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 343 def test_assert_no_enqueued_jobs_with_except_option_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs except: LoggingJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later end end assert_match(/0 .* but 1/, error.message) end
test_assert_no_enqueued_jobs_with_no_block()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 61 def test_assert_no_enqueued_jobs_with_no_block assert_nothing_raised do assert_no_enqueued_jobs end end
test_assert_no_enqueued_jobs_with_only_and_except_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 322 def test_assert_no_enqueued_jobs_with_only_and_except_option error = assert_raise ArgumentError do assert_no_enqueued_jobs only: HelloJob, except: HelloJob do LoggingJob.perform_later end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_no_enqueued_jobs_with_only_and_except_option_as_array()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 382 def test_assert_no_enqueued_jobs_with_only_and_except_option_as_array error = assert_raise ArgumentError do assert_no_enqueued_jobs only: [HelloJob, RescueJob], except: [HelloJob, RescueJob] do LoggingJob.perform_later end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_no_enqueued_jobs_with_only_and_except_option_failure()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 354 def test_assert_no_enqueued_jobs_with_only_and_except_option_failure error = assert_raise ArgumentError do assert_no_enqueued_jobs only: HelloJob, except: HelloJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later end end assert_match(/`:only` and `:except`/, error.message) end
test_assert_no_enqueued_jobs_with_only_option()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 306 def test_assert_no_enqueued_jobs_with_only_option assert_nothing_raised do assert_no_enqueued_jobs only: HelloJob do LoggingJob.perform_later end end end
test_assert_no_enqueued_jobs_with_only_option_as_array()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 365 def test_assert_no_enqueued_jobs_with_only_option_as_array assert_nothing_raised do assert_no_enqueued_jobs only: [HelloJob, RescueJob] do LoggingJob.perform_later end end end
test_assert_no_enqueued_jobs_with_only_option_failure()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 332 def test_assert_no_enqueued_jobs_with_only_option_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs only: HelloJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later end end assert_match(/0 .* but 1/, error.message) end
test_repeated_enqueued_jobs_calls()
click to toggle source
# File activejob/test/cases/test_helper_test.rb, line 22 def test_repeated_enqueued_jobs_calls assert_nothing_raised do assert_enqueued_jobs 1 do HelloJob.perform_later("abdelkader") end end assert_nothing_raised do assert_enqueued_jobs 2 do HelloJob.perform_later("sean") HelloJob.perform_later("yves") end end end