diff options
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/Rakefile | 1 | ||||
-rw-r--r-- | activejob/lib/active_job/arguments.rb | 5 | ||||
-rw-r--r-- | activejob/lib/active_job/callbacks.rb | 4 | ||||
-rw-r--r-- | activejob/lib/active_job/execution.rb | 2 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb | 2 | ||||
-rw-r--r-- | activejob/lib/active_job/test_helper.rb | 15 | ||||
-rw-r--r-- | activejob/test/cases/test_helper_test.rb | 12 |
7 files changed, 33 insertions, 8 deletions
diff --git a/activejob/Rakefile b/activejob/Rakefile index f32c4d2fb2..e47f17b740 100644 --- a/activejob/Rakefile +++ b/activejob/Rakefile @@ -8,7 +8,6 @@ task default: :test task test: 'test:default' task :package -task "package:clean" namespace :test do desc 'Run all adapter tests' diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index 33bd5b4eb3..a5c749e5e7 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -24,7 +24,7 @@ module ActiveJob end # Raised when an unsupported argument type is set as a job argument. We - # currently support NilClass, Fixnum, Float, String, TrueClass, FalseClass, + # currently support NilClass, Integer, Fixnum, Float, String, TrueClass, FalseClass, # Bignum, BigDecimal, and objects that can be represented as GlobalIDs (ex: Active Record). # Raised if you set the key for a Hash something else than a string or # a symbol. Also raised when trying to serialize an object which can't be @@ -34,7 +34,8 @@ module ActiveJob module Arguments extend self # :nodoc: - TYPE_WHITELIST = [ NilClass, Fixnum, Float, String, TrueClass, FalseClass, Bignum, BigDecimal ] + # Calls #uniq since Integer, Fixnum, and Bignum are all the same class on Ruby 2.4+ + TYPE_WHITELIST = [ NilClass, String, Integer, Fixnum, Bignum, Float, BigDecimal, TrueClass, FalseClass ].uniq # Serializes a set of arguments. Whitelisted types are returned # as-is. Arrays/Hashes are serialized element by element. diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb index a6591c6a05..b206522a60 100644 --- a/activejob/lib/active_job/callbacks.rb +++ b/activejob/lib/active_job/callbacks.rb @@ -126,8 +126,8 @@ module ActiveJob set_callback(:enqueue, :after, *filters, &blk) end - # Defines a callback that will get called before and after the - # job is enqueued. + # Defines a callback that will get called around the enqueueing + # of the job. # # class VideoProcessJob < ActiveJob::Base # queue_as :default diff --git a/activejob/lib/active_job/execution.rb b/activejob/lib/active_job/execution.rb index 7c4151fc90..4e4acfc2c2 100644 --- a/activejob/lib/active_job/execution.rb +++ b/activejob/lib/active_job/execution.rb @@ -34,7 +34,7 @@ module ActiveJob perform(*arguments) end rescue => exception - rescue_with_handler(exception) || raise(exception) + rescue_with_handler(exception) || raise end def perform(*) diff --git a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb index 311109e958..163c8eb212 100644 --- a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb @@ -5,7 +5,7 @@ module ActiveJob # == Sucker Punch adapter for Active Job # # Sucker Punch is a single-process Ruby asynchronous processing library. - # This reduces the cost of of hosting on a service like Heroku along + # This reduces the cost of hosting on a service like Heroku along # with the memory footprint of having to maintain additional jobs if # hosting on a dedicated server. All queues can run within a # single application (eg. Rails, Sinatra, etc.) process. diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index 3feb82d432..e16af1947f 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -9,7 +9,7 @@ module ActiveJob to: :queue_adapter def before_setup # :nodoc: - test_adapter = ActiveJob::QueueAdapters::TestAdapter.new + test_adapter = queue_adapter_for_test @old_queue_adapters = (ActiveJob::Base.subclasses << ActiveJob::Base).select do |klass| # only override explicitly set adapters, a quirk of `class_attribute` @@ -32,6 +32,19 @@ module ActiveJob end end + # Specifies the queue adapter to use with all active job test helpers. + # + # Returns an instance of the queue adapter and defaults to + # <tt>ActiveJob::QueueAdapters::TestAdapter</tt>. + # + # Note: The adapter provided by this method must provide some additional + # methods from those expected of a standard <tt>ActiveJob::QueueAdapter</tt> + # in order to be used with the active job test helpers. Refer to + # <tt>ActiveJob::QueueAdapters::TestAdapter</tt>. + def queue_adapter_for_test + ActiveJob::QueueAdapters::TestAdapter.new + end + # Asserts that the number of enqueued jobs matches the given number. # # def test_jobs diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index f7ee763e8a..3d863f5e65 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -509,3 +509,15 @@ class PerformedJobsTest < ActiveJob::TestCase assert_equal 2, ActiveJob::Base.queue_adapter.performed_jobs.count end end + +class OverrideQueueAdapterTest < ActiveJob::TestCase + class CustomQueueAdapter < ActiveJob::QueueAdapters::TestAdapter; end + + def queue_adapter_for_test + CustomQueueAdapter.new + end + + def test_assert_job_has_custom_queue_adapter_set + assert_instance_of CustomQueueAdapter, HelloJob.queue_adapter + end +end |