diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-31 15:45:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 15:45:28 -0500 |
commit | 4f4906b52383468c72aa212c2dab345a3d1b63af (patch) | |
tree | 75f4e2e583fdd2fd8a94eecd6bbb8f3d2747b56b | |
parent | 22f4392bb45adc1dab414d547bff8a2745041597 (diff) | |
parent | 08ddca51c688d8abc4ba56bd11c03de021caad18 (diff) | |
download | rails-4f4906b52383468c72aa212c2dab345a3d1b63af.tar.gz rails-4f4906b52383468c72aa212c2dab345a3d1b63af.tar.bz2 rails-4f4906b52383468c72aa212c2dab345a3d1b63af.zip |
Merge pull request #27850 from apauly/feature/active_job_test_helper
Feature/active job test helper
-rw-r--r-- | activejob/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters/test_adapter.rb | 10 | ||||
-rw-r--r-- | activejob/test/cases/test_helper_test.rb | 11 |
3 files changed, 18 insertions, 7 deletions
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index 5e8d8cb5c9..6f95553ee5 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1,3 +1,7 @@ +* 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 da042cfebf..ec825f12cd 100644 --- a/activejob/lib/active_job/queue_adapters/test_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/test_adapter.rb @@ -24,15 +24,11 @@ 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 @@ -44,11 +40,11 @@ module ActiveJob end def enqueue_or_perform(perform, job, job_data) - if perform + if !perform || filtered?(job) + enqueued_jobs << job_data + else 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 5488ce3d58..372b68c2f5 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -56,6 +56,17 @@ 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 |