diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2016-09-05 17:30:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-05 17:30:31 +0100 |
commit | 1e282dff07eaaede360512be57a831382236f29c (patch) | |
tree | 70498a338b50da20f2a7437bb7cc867cc25256a3 | |
parent | 51c53e19bfbc34c2b3b748786d8b5cc268de1c51 (diff) | |
parent | 0b2197774ccca2a15b01212053143114ee058038 (diff) | |
download | rails-1e282dff07eaaede360512be57a831382236f29c.tar.gz rails-1e282dff07eaaede360512be57a831382236f29c.tar.bz2 rails-1e282dff07eaaede360512be57a831382236f29c.zip |
Merge pull request #26391 from y-yagi/use_descendants_to_get_all_subclasses
use `descendants` to get class that inherited `ActiveJob::Base`
-rw-r--r-- | activejob/lib/active_job/test_helper.rb | 2 | ||||
-rw-r--r-- | activejob/test/cases/test_helper_test.rb | 7 | ||||
-rw-r--r-- | activejob/test/jobs/application_job.rb | 4 | ||||
-rw-r--r-- | activejob/test/jobs/inherited_job.rb | 5 |
4 files changed, 17 insertions, 1 deletions
diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index 35fee7452c..bbd2a0c06c 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -11,7 +11,7 @@ module ActiveJob def before_setup # :nodoc: test_adapter = queue_adapter_for_test - @old_queue_adapters = (ActiveJob::Base.subclasses << ActiveJob::Base).select do |klass| + @old_queue_adapters = (ActiveJob::Base.descendants << ActiveJob::Base).select do |klass| # only override explicitly set adapters, a quirk of `class_attribute` klass.singleton_class.public_instance_methods(false).include?(:_queue_adapter) end.map do |klass| diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index 2398402d5d..253c557cc5 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -5,6 +5,7 @@ require "jobs/hello_job" require "jobs/logging_job" require "jobs/nested_job" require "jobs/rescue_job" +require "jobs/inherited_job" require "models/person" class EnqueuedJobsTest < ActiveJob::TestCase @@ -521,3 +522,9 @@ class OverrideQueueAdapterTest < ActiveJob::TestCase assert_instance_of CustomQueueAdapter, HelloJob.queue_adapter end end + +class InheritedJobTest < ActiveJob::TestCase + def test_queue_adapter_is_test_adapter + assert_instance_of ActiveJob::QueueAdapters::TestAdapter, InheritedJob.queue_adapter + end +end diff --git a/activejob/test/jobs/application_job.rb b/activejob/test/jobs/application_job.rb new file mode 100644 index 0000000000..4a78b890ec --- /dev/null +++ b/activejob/test/jobs/application_job.rb @@ -0,0 +1,4 @@ +require_relative "../support/job_buffer" + +class ApplicationJob < ActiveJob::Base +end diff --git a/activejob/test/jobs/inherited_job.rb b/activejob/test/jobs/inherited_job.rb new file mode 100644 index 0000000000..60fca66f88 --- /dev/null +++ b/activejob/test/jobs/inherited_job.rb @@ -0,0 +1,5 @@ +require_relative "application_job" + +class InheritedJob < ApplicationJob + self.queue_adapter = :inline +end |