CHANGELOG.md 2.6 KB
Newer Older
1
*   Allow `DelayedJob`, `Sidekiq`, `qu`, and `que` to report the job id back to
2
    `ActiveJob::Base` as `provider_job_id`.
3 4 5

    Fixes #18821.

6
    *Kevin Deisz* And *Jeroen van Baarsen*
7

8 9 10 11 12 13
*   `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*

14 15 16 17
*   A generated job now inherents from `app/jobs/application_job.rb` by default.

    *Jeroen van Baarsen*

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
*   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*

51 52 53 54 55 56
*   Allow keyword arguments to be used with Active Job.

    Fixes #18741.

    *Sean Griffin*

57
*   Add `:only` option to `assert_enqueued_jobs`, to check the number of times
58 59 60
    a specific kind of job is enqueued.

    Example:
61 62 63 64 65 66

        def test_logging_job
          assert_enqueued_jobs 1, only: LoggingJob do
            LoggingJob.perform_later
            HelloJob.perform_later('jeremy')
          end
67 68
        end

69
    *George Claghorn*
70

71
*   `ActiveJob::Base.deserialize` delegates to the job class.
R
Robin Dupret 已提交
72 73 74

    Since `ActiveJob::Base#deserialize` can be overridden by subclasses (like
    `ActiveJob::Base#serialize`) this allows jobs to attach arbitrary metadata
75 76 77
    when they get serialized and read it back when they get performed.

    Example:
78

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

84 85 86 87
          def deserialize(job_data)
            super
            @attempt_number = job_data['attempt_number']
          end
88

89 90 91 92
          rescue_from(TimeoutError) do |exception|
            raise exception if @attempt_number > 5
            retry_job(wait: 10)
          end
93 94
        end

R
Robin Dupret 已提交
95
    *Isaac Seymour*
96

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