diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index d561745611..41505fbf83 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -6,10 +6,6 @@ *Yuji Yaginuma* -* Push skipped jobs to `enqueued_jobs` when using `perform_enqueued_jobs` with a `only` filter in tests - - *Alexander Pauly* - * Removed deprecated support to passing the adapter class to `.queue_adapter`. *Rafael Mendonça França* diff --git a/activejob/lib/active_job/queue_adapters/test_adapter.rb b/activejob/lib/active_job/queue_adapters/test_adapter.rb index ec825f12cd..1b633b210e 100644 --- a/activejob/lib/active_job/queue_adapters/test_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/test_adapter.rb @@ -24,27 +24,30 @@ module ActiveJob end def enqueue(job) #:nodoc: + return if filtered?(job) + job_data = job_to_hash(job) enqueue_or_perform(perform_enqueued_jobs, job, job_data) end def enqueue_at(job, timestamp) #:nodoc: + return if filtered?(job) + job_data = job_to_hash(job, at: timestamp) enqueue_or_perform(perform_enqueued_at_jobs, job, job_data) end private - def job_to_hash(job, extras = {}) { job: job.class, args: job.serialize.fetch("arguments"), queue: job.queue_name }.merge!(extras) end def enqueue_or_perform(perform, job, job_data) - if !perform || filtered?(job) - enqueued_jobs << job_data - else + if perform performed_jobs << job_data Base.execute job.serialize + else + enqueued_jobs << job_data end end diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index 2e6357f824..81e75b4374 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -56,17 +56,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