1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
## 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.
*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 ability to configure the queue adapter on a per job basis.
Now different jobs can have different queue adapters without conflicting with
each other.
Example:
class EmailJob < ActiveJob::Base
self.queue_adapter = :sidekiq
end
class ImageProcessingJob < ActiveJob::Base
self.queue_adapter = :delayed_job
end
*tamird*
* 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.
|