diff options
Diffstat (limited to 'activejob/test')
65 files changed, 540 insertions, 37 deletions
diff --git a/activejob/test/adapters/async.rb b/activejob/test/adapters/async.rb index 08eb9658cd..a4fed7c2f7 100644 --- a/activejob/test/adapters/async.rb +++ b/activejob/test/adapters/async.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + ActiveJob::Base.queue_adapter = :async ActiveJob::Base.queue_adapter.immediate = true diff --git a/activejob/test/adapters/backburner.rb b/activejob/test/adapters/backburner.rb index 17ba07b802..bc34c78e9c 100644 --- a/activejob/test/adapters/backburner.rb +++ b/activejob/test/adapters/backburner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "support/backburner/inline" ActiveJob::Base.queue_adapter = :backburner diff --git a/activejob/test/adapters/delayed_job.rb b/activejob/test/adapters/delayed_job.rb index 5f0ee2418c..904b4c3f90 100644 --- a/activejob/test/adapters/delayed_job.rb +++ b/activejob/test/adapters/delayed_job.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + ActiveJob::Base.queue_adapter = :delayed_job -$LOAD_PATH << File.dirname(__FILE__) + "/../support/delayed_job" +$LOAD_PATH << File.expand_path("../support/delayed_job", __dir__) Delayed::Worker.delay_jobs = false Delayed::Worker.backend = :test diff --git a/activejob/test/adapters/inline.rb b/activejob/test/adapters/inline.rb index 24113dfa5a..b1ddcb28f1 100644 --- a/activejob/test/adapters/inline.rb +++ b/activejob/test/adapters/inline.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + ActiveJob::Base.queue_adapter = :inline diff --git a/activejob/test/adapters/qu.rb b/activejob/test/adapters/qu.rb index b89c504091..5b471fa347 100644 --- a/activejob/test/adapters/qu.rb +++ b/activejob/test/adapters/qu.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "qu-immediate" ActiveJob::Base.queue_adapter = :qu diff --git a/activejob/test/adapters/que.rb b/activejob/test/adapters/que.rb index 0c49274a4e..af77b0d4d1 100644 --- a/activejob/test/adapters/que.rb +++ b/activejob/test/adapters/que.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "support/que/inline" ActiveJob::Base.queue_adapter = :que diff --git a/activejob/test/adapters/queue_classic.rb b/activejob/test/adapters/queue_classic.rb index e301a7ca96..73902a5e62 100644 --- a/activejob/test/adapters/queue_classic.rb +++ b/activejob/test/adapters/queue_classic.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require "support/queue_classic/inline" ActiveJob::Base.queue_adapter = :queue_classic diff --git a/activejob/test/adapters/resque.rb b/activejob/test/adapters/resque.rb index af7080358d..ad84a49372 100644 --- a/activejob/test/adapters/resque.rb +++ b/activejob/test/adapters/resque.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + ActiveJob::Base.queue_adapter = :resque Resque.inline = true diff --git a/activejob/test/adapters/sidekiq.rb b/activejob/test/adapters/sidekiq.rb index 8036331ef1..7df1c36488 100644 --- a/activejob/test/adapters/sidekiq.rb +++ b/activejob/test/adapters/sidekiq.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require "sidekiq/testing/inline" ActiveJob::Base.queue_adapter = :sidekiq diff --git a/activejob/test/adapters/sneakers.rb b/activejob/test/adapters/sneakers.rb index 159c0d1906..38d82aa778 100644 --- a/activejob/test/adapters/sneakers.rb +++ b/activejob/test/adapters/sneakers.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require "support/sneakers/inline" ActiveJob::Base.queue_adapter = :sneakers diff --git a/activejob/test/adapters/sucker_punch.rb b/activejob/test/adapters/sucker_punch.rb index 5661b6ee92..04bad984d4 100644 --- a/activejob/test/adapters/sucker_punch.rb +++ b/activejob/test/adapters/sucker_punch.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require "sucker_punch/testing/inline" ActiveJob::Base.queue_adapter = :sucker_punch diff --git a/activejob/test/adapters/test.rb b/activejob/test/adapters/test.rb index 7180b38a57..0a1367dacf 100644 --- a/activejob/test/adapters/test.rb +++ b/activejob/test/adapters/test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveJob::Base.queue_adapter = :test ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true diff --git a/activejob/test/cases/adapter_test.rb b/activejob/test/cases/adapter_test.rb index caf5d44a5e..2c179b2d38 100644 --- a/activejob/test/cases/adapter_test.rb +++ b/activejob/test/cases/adapter_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" class AdapterTest < ActiveSupport::TestCase diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb index 7934d8e556..7e7f854da0 100644 --- a/activejob/test/cases/argument_serialization_test.rb +++ b/activejob/test/cases/argument_serialization_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "active_job/arguments" require "models/person" @@ -10,7 +12,7 @@ class ArgumentSerializationTest < ActiveSupport::TestCase end [ nil, 1, 1.0, 1_000_000_000_000_000_000_000, - "a", true, false, BigDecimal.new(5), + "a", true, false, BigDecimal(5), [ 1, "a" ], { "a" => 1 } ].each do |arg| diff --git a/activejob/test/cases/callbacks_test.rb b/activejob/test/cases/callbacks_test.rb index 8d1c9c3058..df6ce16858 100644 --- a/activejob/test/cases/callbacks_test.rb +++ b/activejob/test/cases/callbacks_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/callback_job" diff --git a/activejob/test/cases/exceptions_test.rb b/activejob/test/cases/exceptions_test.rb index dbe55f7430..22fed0a808 100644 --- a/activejob/test/cases/exceptions_test.rb +++ b/activejob/test/cases/exceptions_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/retry_job" @@ -59,7 +61,7 @@ class ExceptionsTest < ActiveJob::TestCase test "custom handling of job that exceeds retry attempts" do perform_enqueued_jobs do RetryJob.perform_later "CustomCatchError", 6 - assert_equal "Dealt with a job that failed to retry in a custom way after 6 attempts", JobBuffer.last_value + assert_equal "Dealt with a job that failed to retry in a custom way after 6 attempts. Message: CustomCatchError", JobBuffer.last_value end end diff --git a/activejob/test/cases/job_serialization_test.rb b/activejob/test/cases/job_serialization_test.rb index 3f2e300dfa..440051c427 100644 --- a/activejob/test/cases/job_serialization_test.rb +++ b/activejob/test/cases/job_serialization_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/gid_job" require "jobs/hello_job" @@ -44,4 +46,12 @@ class JobSerializationTest < ActiveSupport::TestCase job.deserialize({}) assert_equal "en", job.locale end + + test "serialize stores provider_job_id" do + job = HelloJob.new + assert_nil job.serialize["provider_job_id"] + + job.provider_job_id = "some value set by adapter" + assert_equal job.provider_job_id, job.serialize["provider_job_id"] + end end diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index b37736f859..1f8c4a5573 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "active_support/log_subscriber/test_helper" require "active_support/core_ext/numeric/time" @@ -5,6 +7,7 @@ require "jobs/hello_job" require "jobs/logging_job" require "jobs/overridden_logging_job" require "jobs/nested_job" +require "jobs/rescue_job" require "models/person" class LoggingTest < ActiveSupport::TestCase @@ -124,4 +127,11 @@ class LoggingTest < ActiveSupport::TestCase set_logger ::Logger.new(nil) OverriddenLoggingJob.perform_later "Dummy" end + + def test_job_error_logging + RescueJob.perform_later "other" + rescue RescueJob::OtherError + assert_match(/Performing RescueJob \(Job ID: .*?\) from .*? with arguments:.*other/, @logger.messages) + assert_match(/Error performing RescueJob \(Job ID: .*?\) from .*? in .*ms: RescueJob::OtherError \(Bad hair\):\n.*\brescue_job\.rb:\d+:in `perform'/, @logger.messages) + end end diff --git a/activejob/test/cases/queue_adapter_test.rb b/activejob/test/cases/queue_adapter_test.rb index 9611b0909b..e71cfa49cf 100644 --- a/activejob/test/cases/queue_adapter_test.rb +++ b/activejob/test/cases/queue_adapter_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" module ActiveJob @@ -25,14 +27,19 @@ class QueueAdapterTest < ActiveJob::TestCase base_queue_adapter = ActiveJob::Base.queue_adapter child_job_one = Class.new(ActiveJob::Base) + assert_equal child_job_one.queue_adapter_name, ActiveJob::Base.queue_adapter_name + child_job_one.queue_adapter = :stub_one assert_not_equal ActiveJob::Base.queue_adapter, child_job_one.queue_adapter + assert_equal "stub_one", child_job_one.queue_adapter_name assert_kind_of ActiveJob::QueueAdapters::StubOneAdapter, child_job_one.queue_adapter child_job_two = Class.new(ActiveJob::Base) child_job_two.queue_adapter = :stub_two + assert_equal "stub_two", child_job_two.queue_adapter_name + assert_kind_of ActiveJob::QueueAdapters::StubTwoAdapter, child_job_two.queue_adapter assert_kind_of ActiveJob::QueueAdapters::StubOneAdapter, child_job_one.queue_adapter, "child_job_one's queue adapter should remain unchanged" assert_equal base_queue_adapter, ActiveJob::Base.queue_adapter, "ActiveJob::Base's queue adapter should remain unchanged" diff --git a/activejob/test/cases/queue_naming_test.rb b/activejob/test/cases/queue_naming_test.rb index 0247bc111e..b64a38f91e 100644 --- a/activejob/test/cases/queue_naming_test.rb +++ b/activejob/test/cases/queue_naming_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/hello_job" require "jobs/logging_job" diff --git a/activejob/test/cases/queue_priority_test.rb b/activejob/test/cases/queue_priority_test.rb index 171fb1e593..4b3006ae81 100644 --- a/activejob/test/cases/queue_priority_test.rb +++ b/activejob/test/cases/queue_priority_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/hello_job" diff --git a/activejob/test/cases/queuing_test.rb b/activejob/test/cases/queuing_test.rb index a3ecb15c31..0e843b7215 100644 --- a/activejob/test/cases/queuing_test.rb +++ b/activejob/test/cases/queuing_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/hello_job" require "active_support/core_ext/numeric/time" diff --git a/activejob/test/cases/rescue_test.rb b/activejob/test/cases/rescue_test.rb index afb1b48831..da9c87dbf0 100644 --- a/activejob/test/cases/rescue_test.rb +++ b/activejob/test/cases/rescue_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/rescue_job" require "models/person" diff --git a/activejob/test/cases/test_case_test.rb b/activejob/test/cases/test_case_test.rb index 3db2d9dec7..4ae2add3a8 100644 --- a/activejob/test/cases/test_case_test.rb +++ b/activejob/test/cases/test_case_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/hello_job" require "jobs/logging_job" diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index 2e6357f824..66bcd8f3a0 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "active_support/core_ext/time" require "active_support/core_ext/date" @@ -56,17 +58,6 @@ class EnqueuedJobsTest < ActiveJob::TestCase end end - def test_assert_enqueued_jobs_when_performing_with_only_option - assert_nothing_raised do - assert_enqueued_jobs 1, only: HelloJob do - perform_enqueued_jobs only: LoggingJob do - HelloJob.perform_later("sean") - LoggingJob.perform_later("yves") - end - end - end - end - def test_assert_no_enqueued_jobs_with_no_block assert_nothing_raised do assert_no_enqueued_jobs @@ -117,10 +108,33 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_enqueued_jobs 1, only: HelloJob do HelloJob.perform_later("jeremy") LoggingJob.perform_later + LoggingJob.perform_later end end end + 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 + + 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 + def test_assert_enqueued_jobs_with_only_and_queue_option assert_nothing_raised do assert_enqueued_jobs 1, only: HelloJob, queue: :some_queue do @@ -131,6 +145,28 @@ class EnqueuedJobsTest < ActiveJob::TestCase end end + 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 + + 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 + def test_assert_enqueued_jobs_with_queue_option assert_nothing_raised do assert_enqueued_jobs 2, queue: :default do @@ -152,6 +188,26 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_match(/1 .* but 0/, error.message) end + 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 + + 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 + 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 @@ -163,6 +219,28 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_match(/5 .* but 1/, error.message) end + 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 + + 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 + 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 @@ -173,6 +251,26 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_match(/1 .* but 2/, error.message) end + 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 + + 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 + def test_assert_enqueued_jobs_with_only_option_as_array assert_nothing_raised do assert_enqueued_jobs 2, only: [HelloJob, LoggingJob] do @@ -183,6 +281,28 @@ class EnqueuedJobsTest < ActiveJob::TestCase end end + 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 + + 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 + def test_assert_no_enqueued_jobs_with_only_option assert_nothing_raised do assert_no_enqueued_jobs only: HelloJob do @@ -191,6 +311,24 @@ class EnqueuedJobsTest < ActiveJob::TestCase end end + 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 + + 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 + def test_assert_no_enqueued_jobs_with_only_option_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_jobs only: HelloJob do @@ -202,6 +340,28 @@ class EnqueuedJobsTest < ActiveJob::TestCase assert_match(/0 .* but 1/, error.message) end + 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 + + 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 + def test_assert_no_enqueued_jobs_with_only_option_as_array assert_nothing_raised do assert_no_enqueued_jobs only: [HelloJob, RescueJob] do @@ -210,6 +370,25 @@ class EnqueuedJobsTest < ActiveJob::TestCase end end + 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 + + 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 + def test_assert_enqueued_job assert_enqueued_with(job: LoggingJob, queue: "default") do LoggingJob.set(wait_until: Date.tomorrow.noon).perform_later @@ -295,6 +474,14 @@ class PerformedJobsTest < ActiveJob::TestCase assert_nil queue_adapter.filter end + def test_performed_enqueue_jobs_with_except_option_doesnt_leak_outside_the_block + assert_nil queue_adapter.reject + perform_enqueued_jobs except: HelloJob do + assert_equal HelloJob, queue_adapter.reject + end + assert_nil queue_adapter.reject + end + def test_assert_performed_jobs assert_nothing_raised do assert_performed_jobs 1 do @@ -400,6 +587,26 @@ class PerformedJobsTest < ActiveJob::TestCase end end + def test_assert_performed_jobs_with_except_option + assert_nothing_raised do + assert_performed_jobs 1, except: LoggingJob do + HelloJob.perform_later("jeremy") + LoggingJob.perform_later + end + end + end + + def test_assert_performed_jobs_with_only_and_except_option + error = assert_raise ArgumentError do + assert_performed_jobs 1, only: HelloJob, except: HelloJob do + HelloJob.perform_later("jeremy") + LoggingJob.perform_later + end + end + + assert_match(/`:only` and `:except`/, error.message) + end + def test_assert_performed_jobs_with_only_option_as_array assert_nothing_raised do assert_performed_jobs 2, only: [HelloJob, LoggingJob] do @@ -410,6 +617,28 @@ class PerformedJobsTest < ActiveJob::TestCase end end + def test_assert_performed_jobs_with_except_option_as_array + assert_nothing_raised do + assert_performed_jobs 1, except: [LoggingJob, RescueJob] do + HelloJob.perform_later("jeremy") + LoggingJob.perform_later("stewie") + RescueJob.perform_later("david") + end + end + end + + def test_assert_performed_jobs_with_only_and_except_option_as_array + error = assert_raise ArgumentError do + assert_performed_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 + def test_assert_performed_jobs_with_only_option_and_none_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 1, only: HelloJob do @@ -420,6 +649,26 @@ class PerformedJobsTest < ActiveJob::TestCase assert_match(/1 .* but 0/, error.message) end + def test_assert_performed_jobs_with_except_option_and_none_sent + error = assert_raise ActiveSupport::TestCase::Assertion do + assert_performed_jobs 1, except: LoggingJob do + LoggingJob.perform_later + end + end + + assert_match(/1 .* but 0/, error.message) + end + + def test_assert_performed_jobs_with_only_and_except_option_and_none_sent + error = assert_raise ArgumentError do + assert_performed_jobs 1, only: HelloJob, except: HelloJob do + LoggingJob.perform_later + end + end + + assert_match(/`:only` and `:except`/, error.message) + end + def test_assert_performed_jobs_with_only_option_and_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 5, only: HelloJob do @@ -431,6 +680,28 @@ class PerformedJobsTest < ActiveJob::TestCase assert_match(/5 .* but 1/, error.message) end + def test_assert_performed_jobs_with_except_option_and_too_few_sent + error = assert_raise ActiveSupport::TestCase::Assertion do + assert_performed_jobs 5, except: LoggingJob do + HelloJob.perform_later("jeremy") + 4.times { LoggingJob.perform_later } + end + end + + assert_match(/5 .* but 1/, error.message) + end + + def test_assert_performed_jobs_with_only_and_except_option_and_too_few_sent + error = assert_raise ArgumentError do + assert_performed_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 + def test_assert_performed_jobs_with_only_option_and_too_many_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_performed_jobs 1, only: HelloJob do @@ -441,6 +712,26 @@ class PerformedJobsTest < ActiveJob::TestCase assert_match(/1 .* but 2/, error.message) end + def test_assert_performed_jobs_with_except_option_and_too_many_sent + error = assert_raise ActiveSupport::TestCase::Assertion do + assert_performed_jobs 1, except: LoggingJob do + 2.times { HelloJob.perform_later("jeremy") } + end + end + + assert_match(/1 .* but 2/, error.message) + end + + def test_assert_performed_jobs_with_only_and_except_option_and_too_many_sent + error = assert_raise ArgumentError do + assert_performed_jobs 1, only: HelloJob, except: HelloJob do + 2.times { HelloJob.perform_later("jeremy") } + end + end + + assert_match(/`:only` and `:except`/, error.message) + end + def test_assert_no_performed_jobs_with_only_option assert_nothing_raised do assert_no_performed_jobs only: HelloJob do @@ -449,6 +740,24 @@ class PerformedJobsTest < ActiveJob::TestCase end end + def test_assert_no_performed_jobs_with_except_option + assert_nothing_raised do + assert_no_performed_jobs except: LoggingJob do + LoggingJob.perform_later + end + end + end + + def test_assert_no_performed_jobs_with_only_and_except_option + error = assert_raise ArgumentError do + assert_no_performed_jobs only: HelloJob, except: HelloJob do + LoggingJob.perform_later + end + end + + assert_match(/`:only` and `:except`/, error.message) + end + def test_assert_no_performed_jobs_with_only_option_as_array assert_nothing_raised do assert_no_performed_jobs only: [HelloJob, RescueJob] do @@ -457,6 +766,25 @@ class PerformedJobsTest < ActiveJob::TestCase end end + def test_assert_no_performed_jobs_with_except_option_as_array + assert_nothing_raised do + assert_no_performed_jobs except: [HelloJob, RescueJob] do + HelloJob.perform_later + RescueJob.perform_later + end + end + end + + def test_assert_no_performed_jobs_with_only_and_except_option_as_array + error = assert_raise ArgumentError do + assert_no_performed_jobs only: [HelloJob, RescueJob], except: [HelloJob, RescueJob] do + LoggingJob.perform_later + end + end + + assert_match(/`:only` and `:except`/, error.message) + end + def test_assert_no_performed_jobs_with_only_option_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_performed_jobs only: HelloJob do @@ -468,6 +796,28 @@ class PerformedJobsTest < ActiveJob::TestCase assert_match(/0 .* but 1/, error.message) end + def test_assert_no_performed_jobs_with_except_option_failure + error = assert_raise ActiveSupport::TestCase::Assertion do + assert_no_performed_jobs except: LoggingJob do + HelloJob.perform_later("jeremy") + LoggingJob.perform_later + end + end + + assert_match(/0 .* but 1/, error.message) + end + + def test_assert_no_performed_jobs_with_only_and_except_option_failure + error = assert_raise ArgumentError do + assert_no_performed_jobs only: HelloJob, except: HelloJob do + HelloJob.perform_later("jeremy") + LoggingJob.perform_later + end + end + + assert_match(/`:only` and `:except`/, error.message) + end + def test_assert_performed_job assert_performed_with(job: NestedJob, queue: "default") do NestedJob.perform_later diff --git a/activejob/test/cases/translation_test.rb b/activejob/test/cases/translation_test.rb index 27bfd50985..6a0d6d3e54 100644 --- a/activejob/test/cases/translation_test.rb +++ b/activejob/test/cases/translation_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/translated_hello_job" diff --git a/activejob/test/helper.rb b/activejob/test/helper.rb index db07ecab7a..694232d7ef 100644 --- a/activejob/test/helper.rb +++ b/activejob/test/helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_job" require "support/job_buffer" diff --git a/activejob/test/integration/queuing_test.rb b/activejob/test/integration/queuing_test.rb index 2669c52a1c..32ef485c45 100644 --- a/activejob/test/integration/queuing_test.rb +++ b/activejob/test/integration/queuing_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "helper" require "jobs/logging_job" require "jobs/hello_job" @@ -43,6 +45,13 @@ class QueuingTest < ActiveSupport::TestCase end end + test "should supply a wrapped class name to DelayedJob" do + skip unless adapter_is?(:delayed_job) + ::HelloJob.perform_later + job = Delayed::Job.first + assert_match(/HelloJob \[[0-9a-f-]+\] from DelayedJob\(default\) with arguments: \[\]/, job.name) + end + test "resque JobWrapper should have instance variable queue" do skip unless adapter_is?(:resque) job = ::HelloJob.set(wait: 5.seconds).perform_later diff --git a/activejob/test/jobs/application_job.rb b/activejob/test/jobs/application_job.rb index a009ace51c..d92ffddcb5 100644 --- a/activejob/test/jobs/application_job.rb +++ b/activejob/test/jobs/application_job.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/activejob/test/jobs/callback_job.rb b/activejob/test/jobs/callback_job.rb index ca2a8e031a..436cb55492 100644 --- a/activejob/test/jobs/callback_job.rb +++ b/activejob/test/jobs/callback_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CallbackJob < ActiveJob::Base before_perform ->(job) { job.history << "CallbackJob ran before_perform" } after_perform ->(job) { job.history << "CallbackJob ran after_perform" } diff --git a/activejob/test/jobs/gid_job.rb b/activejob/test/jobs/gid_job.rb index c7cfa6e7a2..2136f57e05 100644 --- a/activejob/test/jobs/gid_job.rb +++ b/activejob/test/jobs/gid_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class GidJob < ActiveJob::Base diff --git a/activejob/test/jobs/hello_job.rb b/activejob/test/jobs/hello_job.rb index 126fefae00..404df6150a 100644 --- a/activejob/test/jobs/hello_job.rb +++ b/activejob/test/jobs/hello_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class HelloJob < ActiveJob::Base diff --git a/activejob/test/jobs/inherited_job.rb b/activejob/test/jobs/inherited_job.rb index 60fca66f88..14f852ed06 100644 --- a/activejob/test/jobs/inherited_job.rb +++ b/activejob/test/jobs/inherited_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "application_job" class InheritedJob < ApplicationJob diff --git a/activejob/test/jobs/kwargs_job.rb b/activejob/test/jobs/kwargs_job.rb index 9f9d809673..b86b06bada 100644 --- a/activejob/test/jobs/kwargs_job.rb +++ b/activejob/test/jobs/kwargs_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class KwargsJob < ActiveJob::Base diff --git a/activejob/test/jobs/logging_job.rb b/activejob/test/jobs/logging_job.rb index 119b32fa67..4605fa6937 100644 --- a/activejob/test/jobs/logging_job.rb +++ b/activejob/test/jobs/logging_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class LoggingJob < ActiveJob::Base def perform(dummy) logger.info "Dummy, here is it: #{dummy}" diff --git a/activejob/test/jobs/nested_job.rb b/activejob/test/jobs/nested_job.rb index 21b7692cd1..aafad0dba9 100644 --- a/activejob/test/jobs/nested_job.rb +++ b/activejob/test/jobs/nested_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class NestedJob < ActiveJob::Base def perform LoggingJob.perform_later "NestedJob" diff --git a/activejob/test/jobs/overridden_logging_job.rb b/activejob/test/jobs/overridden_logging_job.rb index 2b17a65142..2ee363637d 100644 --- a/activejob/test/jobs/overridden_logging_job.rb +++ b/activejob/test/jobs/overridden_logging_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class OverriddenLoggingJob < ActiveJob::Base def perform(dummy) logger.info "Dummy, here is it: #{dummy}" diff --git a/activejob/test/jobs/provider_jid_job.rb b/activejob/test/jobs/provider_jid_job.rb index 0c8ba040f5..dacd09afdc 100644 --- a/activejob/test/jobs/provider_jid_job.rb +++ b/activejob/test/jobs/provider_jid_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class ProviderJidJob < ActiveJob::Base diff --git a/activejob/test/jobs/queue_adapter_job.rb b/activejob/test/jobs/queue_adapter_job.rb index 160dfd74ec..1c31a60ba2 100644 --- a/activejob/test/jobs/queue_adapter_job.rb +++ b/activejob/test/jobs/queue_adapter_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class QueueAdapterJob < ActiveJob::Base self.queue_adapter = :inline end diff --git a/activejob/test/jobs/queue_as_job.rb b/activejob/test/jobs/queue_as_job.rb index 7dc318e736..0feee99e87 100644 --- a/activejob/test/jobs/queue_as_job.rb +++ b/activejob/test/jobs/queue_as_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class QueueAsJob < ActiveJob::Base diff --git a/activejob/test/jobs/rescue_job.rb b/activejob/test/jobs/rescue_job.rb index ef8f777437..d142cec1ea 100644 --- a/activejob/test/jobs/rescue_job.rb +++ b/activejob/test/jobs/rescue_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class RescueJob < ActiveJob::Base @@ -19,7 +21,7 @@ class RescueJob < ActiveJob::Base when "david" raise ArgumentError, "Hair too good" when "other" - raise OtherError + raise OtherError, "Bad hair" else JobBuffer.add("performed beautifully") end diff --git a/activejob/test/jobs/retry_job.rb b/activejob/test/jobs/retry_job.rb index c02febc50c..9aa99d9a21 100644 --- a/activejob/test/jobs/retry_job.rb +++ b/activejob/test/jobs/retry_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" require "active_support/core_ext/integer/inflections" @@ -15,7 +17,7 @@ class RetryJob < ActiveJob::Base retry_on ShortWaitTenAttemptsError, wait: 1.second, attempts: 10 retry_on ExponentialWaitTenAttemptsError, wait: :exponentially_longer, attempts: 10 retry_on CustomWaitTenAttemptsError, wait: ->(executions) { executions * 2 }, attempts: 10 - retry_on(CustomCatchError) { |job, exception| JobBuffer.add("Dealt with a job that failed to retry in a custom way after #{job.arguments.second} attempts") } + retry_on(CustomCatchError) { |job, exception| JobBuffer.add("Dealt with a job that failed to retry in a custom way after #{job.arguments.second} attempts. Message: #{exception.message}") } discard_on DiscardableError def perform(raising, attempts) diff --git a/activejob/test/jobs/translated_hello_job.rb b/activejob/test/jobs/translated_hello_job.rb index 56e9f147b9..a0a68b4040 100644 --- a/activejob/test/jobs/translated_hello_job.rb +++ b/activejob/test/jobs/translated_hello_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "../support/job_buffer" class TranslatedHelloJob < ActiveJob::Base diff --git a/activejob/test/models/person.rb b/activejob/test/models/person.rb index b5d68ad9c1..9a3bfab25f 100644 --- a/activejob/test/models/person.rb +++ b/activejob/test/models/person.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Person class RecordNotFound < StandardError; end diff --git a/activejob/test/support/backburner/inline.rb b/activejob/test/support/backburner/inline.rb index 9758332b6f..6c708c0b7b 100644 --- a/activejob/test/support/backburner/inline.rb +++ b/activejob/test/support/backburner/inline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "backburner" Backburner::Worker.class_eval do diff --git a/activejob/test/support/delayed_job/delayed/backend/test.rb b/activejob/test/support/delayed_job/delayed/backend/test.rb index 98d731ff1e..1691896b7c 100644 --- a/activejob/test/support/delayed_job/delayed/backend/test.rb +++ b/activejob/test/support/delayed_job/delayed/backend/test.rb @@ -1,4 +1,6 @@ -#copied from https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb +# frozen_string_literal: true + +# copied from https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb require "ostruct" # An in-memory backend suitable only for testing. Tries to behave as if it were an ORM. @@ -19,8 +21,7 @@ module Delayed include Delayed::Backend::Base - cattr_accessor :id - self.id = 0 + cattr_accessor :id, default: 0 def initialize(hash = {}) self.attempts = 0 @@ -76,7 +77,7 @@ module Delayed self.locked_by = worker end - return true + true end def self.db_time_now diff --git a/activejob/test/support/integration/adapters/async.rb b/activejob/test/support/integration/adapters/async.rb index 44ab98437a..ba9674d7a1 100644 --- a/activejob/test/support/integration/adapters/async.rb +++ b/activejob/test/support/integration/adapters/async.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AsyncJobsManager def setup ActiveJob::Base.queue_adapter = :async diff --git a/activejob/test/support/integration/adapters/backburner.rb b/activejob/test/support/integration/adapters/backburner.rb index 2e194933a1..eb179011d9 100644 --- a/activejob/test/support/integration/adapters/backburner.rb +++ b/activejob/test/support/integration/adapters/backburner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module BackburnerJobsManager def setup ActiveJob::Base.queue_adapter = :backburner diff --git a/activejob/test/support/integration/adapters/delayed_job.rb b/activejob/test/support/integration/adapters/delayed_job.rb index 2adbbcd88f..fc9bae47fa 100644 --- a/activejob/test/support/integration/adapters/delayed_job.rb +++ b/activejob/test/support/integration/adapters/delayed_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "delayed_job" require "delayed_job_active_record" @@ -16,5 +18,6 @@ module DelayedJobJobsManager def stop_workers @worker.stop + @thread.join end end diff --git a/activejob/test/support/integration/adapters/inline.rb b/activejob/test/support/integration/adapters/inline.rb index e06b34c976..10a97fb941 100644 --- a/activejob/test/support/integration/adapters/inline.rb +++ b/activejob/test/support/integration/adapters/inline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module InlineJobsManager def setup ActiveJob::Base.queue_adapter = :inline diff --git a/activejob/test/support/integration/adapters/qu.rb b/activejob/test/support/integration/adapters/qu.rb index 71819f5a55..67db03e279 100644 --- a/activejob/test/support/integration/adapters/qu.rb +++ b/activejob/test/support/integration/adapters/qu.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QuJobsManager def setup require "qu-rails" diff --git a/activejob/test/support/integration/adapters/que.rb b/activejob/test/support/integration/adapters/que.rb index 20faee3427..2a771b08c7 100644 --- a/activejob/test/support/integration/adapters/que.rb +++ b/activejob/test/support/integration/adapters/que.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QueJobsManager def setup require "sequel" diff --git a/activejob/test/support/integration/adapters/queue_classic.rb b/activejob/test/support/integration/adapters/queue_classic.rb index 369693e947..1b0685a971 100644 --- a/activejob/test/support/integration/adapters/queue_classic.rb +++ b/activejob/test/support/integration/adapters/queue_classic.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QueueClassicJobsManager def setup ENV["QC_DATABASE_URL"] ||= "postgres:///active_jobs_qc_int_test" diff --git a/activejob/test/support/integration/adapters/resque.rb b/activejob/test/support/integration/adapters/resque.rb index a21a1786c9..2ed8302277 100644 --- a/activejob/test/support/integration/adapters/resque.rb +++ b/activejob/test/support/integration/adapters/resque.rb @@ -1,11 +1,14 @@ +# frozen_string_literal: true + module ResqueJobsManager def setup ActiveJob::Base.queue_adapter = :resque - Resque.redis = Redis::Namespace.new "active_jobs_int_test", redis: Redis.connect(url: "redis://127.0.0.1:6379/12", thread_safe: true) + Resque.redis = Redis::Namespace.new "active_jobs_int_test", redis: Redis.new(url: "redis://127.0.0.1:6379/12", thread_safe: true) Resque.logger = Rails.logger unless can_run? puts "Cannot run integration tests for resque. To be able to run integration tests for resque you need to install and start redis.\n" - exit + status = ENV["CI"] ? false : true + exit status end end @@ -39,11 +42,8 @@ module ResqueJobsManager end def can_run? - begin - Resque.redis.client.connect - rescue - return false - end - true + Resque.redis.ping == "PONG" + rescue + false end end diff --git a/activejob/test/support/integration/adapters/sidekiq.rb b/activejob/test/support/integration/adapters/sidekiq.rb index bbb575f6da..c79de12eaf 100644 --- a/activejob/test/support/integration/adapters/sidekiq.rb +++ b/activejob/test/support/integration/adapters/sidekiq.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "sidekiq/api" require "sidekiq/testing" @@ -8,7 +10,8 @@ module SidekiqJobsManager ActiveJob::Base.queue_adapter = :sidekiq unless can_run? puts "Cannot run integration tests for sidekiq. To be able to run integration tests for sidekiq you need to install and start redis.\n" - exit + status = ENV["CI"] ? false : true + exit status end end @@ -28,7 +31,7 @@ module SidekiqJobsManager # Sidekiq is not warning-clean :( $VERBOSE = false - $stdin.reopen("/dev/null") + $stdin.reopen(File::NULL) $stdout.sync = true $stderr.sync = true @@ -48,6 +51,7 @@ module SidekiqJobsManager self_write.puts("TERM") end + require "sidekiq/cli" require "sidekiq/launcher" sidekiq = Sidekiq::Launcher.new(queues: ["integration_tests"], environment: "test", diff --git a/activejob/test/support/integration/adapters/sneakers.rb b/activejob/test/support/integration/adapters/sneakers.rb index 1c8dfaca59..965e6e2e6c 100644 --- a/activejob/test/support/integration/adapters/sneakers.rb +++ b/activejob/test/support/integration/adapters/sneakers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "sneakers/runner" require "sneakers/publisher" require "timeout" diff --git a/activejob/test/support/integration/adapters/sucker_punch.rb b/activejob/test/support/integration/adapters/sucker_punch.rb index 9c0d66b469..099d412c8f 100644 --- a/activejob/test/support/integration/adapters/sucker_punch.rb +++ b/activejob/test/support/integration/adapters/sucker_punch.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SuckerPunchJobsManager def setup ActiveJob::Base.queue_adapter = :sucker_punch diff --git a/activejob/test/support/integration/dummy_app_template.rb b/activejob/test/support/integration/dummy_app_template.rb index 29a5691f30..7ea78c3350 100644 --- a/activejob/test/support/integration/dummy_app_template.rb +++ b/activejob/test/support/integration/dummy_app_template.rb @@ -1,11 +1,11 @@ +# frozen_string_literal: true + if ENV["AJ_ADAPTER"] == "delayed_job" generate "delayed_job:active_record", "--quiet" end -rails_command("db:migrate") - initializer "activejob.rb", <<-CODE -require "#{File.expand_path("../jobs_manager.rb", __FILE__)}" +require "#{File.expand_path("jobs_manager.rb", __dir__)}" JobsManager.current_manager.setup CODE diff --git a/activejob/test/support/integration/helper.rb b/activejob/test/support/integration/helper.rb index 626b932cce..a02d874e2e 100644 --- a/activejob/test/support/integration/helper.rb +++ b/activejob/test/support/integration/helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + puts "\n\n*** rake aj:integration:#{ENV['AJ_ADAPTER']} ***\n" ENV["RAILS_ENV"] = "test" @@ -7,7 +9,7 @@ require "rails/generators/rails/app/app_generator" require "tmpdir" dummy_app_path = Dir.mktmpdir + "/dummy" -dummy_app_template = File.expand_path("../dummy_app_template.rb", __FILE__) +dummy_app_template = File.expand_path("dummy_app_template.rb", __dir__) args = Rails::Generators::ARGVScrubber.new(["new", dummy_app_path, "--skip-gemfile", "--skip-bundle", "--skip-git", "--skip-spring", "-d", "sqlite3", "--skip-javascript", "--force", "--quiet", "--template", dummy_app_template]).prepare! @@ -16,6 +18,7 @@ Rails::Generators::AppGenerator.start args require "#{dummy_app_path}/config/environment.rb" ActiveRecord::Migrator.migrations_paths = [ Rails.root.join("db/migrate").to_s ] +ActiveRecord::Tasks::DatabaseTasks.migrate require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! diff --git a/activejob/test/support/integration/jobs_manager.rb b/activejob/test/support/integration/jobs_manager.rb index 488756437b..4775f52b2f 100644 --- a/activejob/test/support/integration/jobs_manager.rb +++ b/activejob/test/support/integration/jobs_manager.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class JobsManager @@managers = {} attr :adapter_name diff --git a/activejob/test/support/integration/test_case_helpers.rb b/activejob/test/support/integration/test_case_helpers.rb index 41bf9c89d1..f02a32a38e 100644 --- a/activejob/test/support/integration/test_case_helpers.rb +++ b/activejob/test/support/integration/test_case_helpers.rb @@ -1,4 +1,5 @@ -require "active_support/core_ext/string/inflections" +# frozen_string_literal: true + require "support/integration/jobs_manager" module TestCaseHelpers @@ -28,8 +29,7 @@ module TestCaseHelpers end def adapter_is?(*adapter_class_symbols) - adapter = ActiveJob::Base.queue_adapter.class.name.demodulize.chomp("Adapter").underscore - adapter_class_symbols.map(&:to_s).include? adapter + adapter_class_symbols.map(&:to_s).include? ActiveJob::Base.queue_adapter_name end def wait_for_jobs_to_finish_for(seconds = 60) diff --git a/activejob/test/support/job_buffer.rb b/activejob/test/support/job_buffer.rb index 620cb5288d..45a6437685 100644 --- a/activejob/test/support/job_buffer.rb +++ b/activejob/test/support/job_buffer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module JobBuffer class << self def clear diff --git a/activejob/test/support/que/inline.rb b/activejob/test/support/que/inline.rb index 55eb0d01ef..4ca65c1cd4 100644 --- a/activejob/test/support/que/inline.rb +++ b/activejob/test/support/que/inline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "que" Que::Job.class_eval do diff --git a/activejob/test/support/queue_classic/inline.rb b/activejob/test/support/queue_classic/inline.rb index dcd834ecce..ca3cd4581b 100644 --- a/activejob/test/support/queue_classic/inline.rb +++ b/activejob/test/support/queue_classic/inline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "queue_classic" module QC diff --git a/activejob/test/support/sneakers/inline.rb b/activejob/test/support/sneakers/inline.rb index cf102ae5c2..92b69ee3bc 100644 --- a/activejob/test/support/sneakers/inline.rb +++ b/activejob/test/support/sneakers/inline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "sneakers" module Sneakers |