aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
Diffstat (limited to 'activejob')
-rw-r--r--activejob/CHANGELOG.md160
-rw-r--r--activejob/Rakefile4
-rw-r--r--activejob/lib/active_job/arguments.rb5
-rw-r--r--activejob/lib/active_job/callbacks.rb4
-rw-r--r--activejob/lib/active_job/execution.rb2
-rw-r--r--activejob/lib/active_job/gem_version.rb4
-rw-r--r--activejob/test/support/integration/test_case_helpers.rb4
7 files changed, 14 insertions, 169 deletions
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md
index efe46ce5ab..5e72c67aea 100644
--- a/activejob/CHANGELOG.md
+++ b/activejob/CHANGELOG.md
@@ -1,160 +1,2 @@
-* Enable class reloading prior to job dispatch, and ensure Active Record
- connections are returned to the pool when jobs are run in separate threads.
- *Matthew Draper*
-
-* Tune the async adapter for low-footprint dev/test usage. Use a single
- thread pool for all queues and limit to 0 to #CPU total threads, down from
- 2 to 10*#CPU per queue.
-
- *Jeremy Daer*
-
-
-## Rails 5.0.0.beta3 (February 24, 2016) ##
-
-* Change the default adapter from inline to async. It's a better default as tests will then not mistakenly
- come to rely on behavior happening synchronously. This is especially important with things like jobs kicked off
- in Active Record lifecycle callbacks.
-
- *DHH*
-
-
-## Rails 5.0.0.beta2 (February 01, 2016) ##
-
-* No changes.
-
-
-## Rails 5.0.0.beta1 (December 18, 2015) ##
-
-* Fixed serializing `:at` option for `assert_enqueued_with`
- and `assert_performed_with`.
-
- *Wojciech Wnętrzak*
-
-* Support passing array to `assert_enqueued_jobs` in `:only` option.
-
- *Wojciech Wnętrzak*
-
-* Add job priorities to Active Job.
-
- *wvengen*
-
-* Implement a simple `AsyncJob` processor and associated `AsyncAdapter` that
- queue jobs to a `concurrent-ruby` thread pool.
-
- *Jerry D'Antonio*
-
-* Implement `provider_job_id` for `queue_classic` adapter. This requires the
- latest, currently unreleased, version of queue_classic.
-
- *Yves Senn*
-
-* `assert_enqueued_with` and `assert_performed_with` now returns the matched
- job instance for further assertions.
-
- *Jean Boussier*
-
-* Include `I18n.locale` into job serialization/deserialization and use it around
- `perform`.
-
- Fixes #20799.
-
- *Johannes Opper*
-
-* Allow `DelayedJob`, `Sidekiq`, `qu`, and `que` to report the job id back to
- `ActiveJob::Base` as `provider_job_id`.
-
- Fixes #18821.
-
- *Kevin Deisz*, *Jeroen van Baarsen*
-
-* `assert_enqueued_jobs` and `assert_performed_jobs` in block form use the
- given number as expected value. This makes the error message much easier to
- understand.
-
- *y-yagi*
-
-* A generated job now inherits from `app/jobs/application_job.rb` by default.
-
- *Jeroen van Baarsen*
-
-* Add an `:only` option to `perform_enqueued_jobs` to filter jobs based on
- type.
-
- This allows specific jobs to be tested, while preventing others from
- being performed unnecessarily.
-
- Example:
-
- def test_hello_job
- assert_performed_jobs 1, only: HelloJob do
- HelloJob.perform_later('jeremy')
- LoggingJob.perform_later
- end
- end
-
- An array may also be specified, to support testing multiple jobs.
-
- Example:
-
- def test_hello_and_logging_jobs
- assert_nothing_raised do
- assert_performed_jobs 2, only: [HelloJob, LoggingJob] do
- HelloJob.perform_later('jeremy')
- LoggingJob.perform_later('stewie')
- RescueJob.perform_later('david')
- end
- end
- end
-
- Fixes #18802.
-
- *Michael Ryan*
-
-* Allow keyword arguments to be used with Active Job.
-
- Fixes #18741.
-
- *Sean Griffin*
-
-* Add `:only` option to `assert_enqueued_jobs`, to check the number of times
- a specific kind of job is enqueued.
-
- Example:
-
- def test_logging_job
- assert_enqueued_jobs 1, only: LoggingJob do
- LoggingJob.perform_later
- HelloJob.perform_later('jeremy')
- end
- end
-
- *George Claghorn*
-
-* `ActiveJob::Base.deserialize` delegates to the job class.
-
- Since `ActiveJob::Base#deserialize` can be overridden by subclasses (like
- `ActiveJob::Base#serialize`) this allows jobs to attach arbitrary metadata
- when they get serialized and read it back when they get performed.
-
- Example:
-
- class DeliverWebhookJob < ActiveJob::Base
- def serialize
- super.merge('attempt_number' => (@attempt_number || 0) + 1)
- end
-
- def deserialize(job_data)
- super
- @attempt_number = job_data['attempt_number']
- end
-
- rescue_from(TimeoutError) do |exception|
- raise exception if @attempt_number > 5
- retry_job(wait: 10)
- end
- end
-
- *Isaac Seymour*
-
-Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activejob/CHANGELOG.md) for previous changes.
+Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activejob/CHANGELOG.md) for previous changes.
diff --git a/activejob/Rakefile b/activejob/Rakefile
index 2a853b4b6b..e47f17b740 100644
--- a/activejob/Rakefile
+++ b/activejob/Rakefile
@@ -1,13 +1,13 @@
require 'rake/testtask'
-ACTIVEJOB_ADAPTERS = %w(async inline delayed_job qu que queue_classic resque sidekiq sneakers sucker_punch backburner test)
+#TODO: add qu back to the list after it support Rails 5.1
+ACTIVEJOB_ADAPTERS = %w(async inline delayed_job que queue_classic resque sidekiq sneakers sucker_punch backburner test)
ACTIVEJOB_ADAPTERS -= %w(queue_classic) if defined?(JRUBY_VERSION)
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/gem_version.rb b/activejob/lib/active_job/gem_version.rb
index be4fabf545..0d50c27938 100644
--- a/activejob/lib/active_job/gem_version.rb
+++ b/activejob/lib/active_job/gem_version.rb
@@ -6,9 +6,9 @@ module ActiveJob
module VERSION
MAJOR = 5
- MINOR = 0
+ MINOR = 1
TINY = 0
- PRE = "beta3"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/activejob/test/support/integration/test_case_helpers.rb b/activejob/test/support/integration/test_case_helpers.rb
index 9897f76fd0..fdf25c67a1 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/concern'
+require 'active_support/core_ext/string/inflections'
require 'support/integration/jobs_manager'
module TestCaseHelpers
@@ -28,7 +29,8 @@ module TestCaseHelpers
end
def adapter_is?(*adapter_class_symbols)
- adapter_class_symbols.map(&:to_s).include?(ActiveJob::Base.queue_adapter.class.name.split("::").last.gsub(/Adapter$/, '').underscore)
+ adapter = ActiveJob::Base.queue_adapter.class.name.demodulize.chomp('Adapter').underscore
+ adapter_class_symbols.map(&:to_s).include? adapter
end
def wait_for_jobs_to_finish_for(seconds=60)