Rails 5.0.0.beta4 (April 27, 2016)
Enable class reloading prior to job dispatch, and ensure Active Record connections are returned to the pool when jobs are run in separate threads.
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.
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.
Rails 5.0.0.beta2 (February 01, 2016)
- No changes.
Rails 5.0.0.beta1 (December 18, 2015)
Support passing array to
Add job priorities to Active Job.
Implement a simple
AsyncJobprocessor and associated
AsyncAdapterthat queue jobs to a
queue_classicadapter. This requires the latest, currently unreleased, version of queue_classic.
assert_performed_withnow returns the matched job instance for further assertions.
I18n.localeinto job serialization/deserialization and use it around
queto report the job id back to
Kevin Deisz, Jeroen van Baarsen
assert_performed_jobsin block form use the given number as expected value. This makes the error message much easier to understand.
A generated job now inherits from
Jeroen van Baarsen
perform_enqueued_jobsto filter jobs based on type.
This allows specific jobs to be tested, while preventing others from being performed unnecessarily.
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.
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
Allow keyword arguments to be used with Active Job.
assert_enqueued_jobs, to check the number of times a specific kind of job is enqueued.
def test_logging_job assert_enqueued_jobs 1, only: LoggingJob do LoggingJob.perform_later HelloJob.perform_later('jeremy') end end
ActiveJob::Base.deserializedelegates to the job class.
ActiveJob::Base#deserializecan 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.
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
Please check 4-2-stable for previous changes.