CHANGELOG.md 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
*  Add :only option to assert_enqueued_jobs

   With the option, assert_enqueued_jobs will 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

   *George Claghorn*

R
Robin Dupret 已提交
14
*  `ActiveJob::Base.deserialize` delegates to the job class
15

R
Robin Dupret 已提交
16 17 18 19

    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:
20 21 22 23 24 25 26

      class DeliverWebhookJob < ActiveJob::Base
        def serialize
          super.merge('attempt_number' => (@attempt_number || 0) + 1)
        end

        def deserialize(job_data)
R
Robin Dupret 已提交
27
          super
28 29 30
          @attempt_number = job_data['attempt_number']
        end

R
Robin Dupret 已提交
31 32
        rescue_from(TimeoutError) do |exception|
          raise exception if @attempt_number > 5
33 34 35 36
          retry_job(wait: 10)
        end
      end

R
Robin Dupret 已提交
37
    *Isaac Seymour*
38 39


40
Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activejob/CHANGELOG.md) for previous changes.