Rails 5.0.1.rc1 (December 01, 2016)
Added instance variable
This will fix issues in resque-scheduler
#job_to_hashmethod, so we can use
#remove_delayedmethod in resque-scheduler smoothly.
Rails 5.0.0 (June 30, 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.
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.
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
Add ability to configure the queue adapter on a per job basis.
Now different jobs can have different queue adapters without conflicting with each other.
class EmailJob < ActiveJob::Base self.queue_adapter = :sidekiq end class ImageProcessingJob < ActiveJob::Base self.queue_adapter = :delayed_job end
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.