activejob 5.2.1.1 → 5.2.2.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/lib/active_job/arguments.rb +13 -4
- data/lib/active_job/execution.rb +3 -3
- data/lib/active_job/gem_version.rb +2 -2
- data/lib/active_job/test_helper.rb +17 -9
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 67232e1851713cf072bc96e4451b10930205933fcce173ac4101f056df36ccce
|
|
4
|
+
data.tar.gz: 9a3a46381e090c488ab44073e3413e6c2da119179d1bf4a3962c3dac50bb440b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06b88781fd187207d998377c715f971fe7f42fee7a44995fec6ba34b3aa64642b4f7e9e747b3d237ce2749bab6183bf3d427a6313bf7bf55cfd54392c29f8428
|
|
7
|
+
data.tar.gz: 6b1827f4f4583812e1d997d1a0d938c844359c09844c42373480851ba0253f7f1eb557c4e7ccdf49a5a94ceab09a55911d98b7411eab4dae56b36b3f0cde4f9c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## Rails 5.2.2.rc1 (November 28, 2018) ##
|
|
2
|
+
|
|
3
|
+
* Make sure `assert_enqueued_with()` & `assert_performed_with()` work reliably with hash arguments.
|
|
4
|
+
|
|
5
|
+
*Sharang Dashputre*
|
|
6
|
+
|
|
7
|
+
* Restore `ActionController::Parameters` support to `ActiveJob::Arguments.serialize`.
|
|
8
|
+
|
|
9
|
+
*Bernie Chiu*
|
|
10
|
+
|
|
11
|
+
* Restore `HashWithIndifferentAccess` support to `ActiveJob::Arguments.deserialize`.
|
|
12
|
+
|
|
13
|
+
*Gannon McGibbon*
|
|
14
|
+
|
|
15
|
+
* Include deserialized arguments in job instances returned from
|
|
16
|
+
`assert_enqueued_with` and `assert_performed_with`
|
|
17
|
+
|
|
18
|
+
*Alan Wu*
|
|
19
|
+
|
|
20
|
+
* Increment execution count before deserialize arguments.
|
|
21
|
+
|
|
22
|
+
Currently, the execution count increments after deserializes arguments.
|
|
23
|
+
Therefore, if an error occurs with deserialize, it retries indefinitely.
|
|
24
|
+
|
|
25
|
+
*Yuji Yaginuma*
|
|
26
|
+
|
|
27
|
+
|
|
1
28
|
## Rails 5.2.1.1 (November 27, 2018) ##
|
|
2
29
|
|
|
3
30
|
* Do not deserialize GlobalID objects that were not generated by Active Job.
|
data/lib/active_job/arguments.rb
CHANGED
|
@@ -61,14 +61,14 @@ module ActiveJob
|
|
|
61
61
|
when Array
|
|
62
62
|
argument.map { |arg| serialize_argument(arg) }
|
|
63
63
|
when ActiveSupport::HashWithIndifferentAccess
|
|
64
|
-
|
|
65
|
-
result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true)
|
|
66
|
-
result
|
|
64
|
+
serialize_indifferent_hash(argument)
|
|
67
65
|
when Hash
|
|
68
66
|
symbol_keys = argument.each_key.grep(Symbol).map(&:to_s)
|
|
69
67
|
result = serialize_hash(argument)
|
|
70
68
|
result[SYMBOL_KEYS_KEY] = symbol_keys
|
|
71
69
|
result
|
|
70
|
+
when -> (arg) { arg.respond_to?(:permitted?) }
|
|
71
|
+
serialize_indifferent_hash(argument.to_h)
|
|
72
72
|
else
|
|
73
73
|
raise SerializationError.new("Unsupported argument type: #{argument.class.name}")
|
|
74
74
|
end
|
|
@@ -136,8 +136,17 @@ module ActiveJob
|
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
+
def serialize_indifferent_hash(indifferent_hash)
|
|
140
|
+
result = serialize_hash(indifferent_hash)
|
|
141
|
+
result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true)
|
|
142
|
+
result
|
|
143
|
+
end
|
|
144
|
+
|
|
139
145
|
def transform_symbol_keys(hash, symbol_keys)
|
|
140
|
-
|
|
146
|
+
# NOTE: HashWithIndifferentAccess#transform_keys always
|
|
147
|
+
# returns stringified keys with indifferent access
|
|
148
|
+
# so we call #to_h here to ensure keys are symbolized.
|
|
149
|
+
hash.to_h.transform_keys do |key|
|
|
141
150
|
if symbol_keys.include?(key)
|
|
142
151
|
key.to_sym
|
|
143
152
|
else
|
data/lib/active_job/execution.rb
CHANGED
|
@@ -31,11 +31,11 @@ module ActiveJob
|
|
|
31
31
|
#
|
|
32
32
|
# MyJob.new(*args).perform_now
|
|
33
33
|
def perform_now
|
|
34
|
+
# Guard against jobs that were persisted before we started counting executions by zeroing out nil counters
|
|
35
|
+
self.executions = (executions || 0) + 1
|
|
36
|
+
|
|
34
37
|
deserialize_arguments_if_needed
|
|
35
38
|
run_callbacks :perform do
|
|
36
|
-
# Guard against jobs that were persisted before we started counting executions by zeroing out nil counters
|
|
37
|
-
self.executions = (executions || 0) + 1
|
|
38
|
-
|
|
39
39
|
perform(*arguments)
|
|
40
40
|
end
|
|
41
41
|
rescue => exception
|
|
@@ -300,11 +300,12 @@ module ActiveJob
|
|
|
300
300
|
def assert_enqueued_with(job: nil, args: nil, at: nil, queue: nil)
|
|
301
301
|
original_enqueued_jobs_count = enqueued_jobs.count
|
|
302
302
|
expected = { job: job, args: args, at: at, queue: queue }.compact
|
|
303
|
-
|
|
303
|
+
expected_args = prepare_args_for_assertion(expected)
|
|
304
304
|
yield
|
|
305
305
|
in_block_jobs = enqueued_jobs.drop(original_enqueued_jobs_count)
|
|
306
306
|
matching_job = in_block_jobs.find do |in_block_job|
|
|
307
|
-
|
|
307
|
+
deserialized_job = deserialize_args_for_assertion(in_block_job)
|
|
308
|
+
expected_args.all? { |key, value| value == deserialized_job[key] }
|
|
308
309
|
end
|
|
309
310
|
assert matching_job, "No enqueued job found with #{expected}"
|
|
310
311
|
instantiate_job(matching_job)
|
|
@@ -324,11 +325,12 @@ module ActiveJob
|
|
|
324
325
|
def assert_performed_with(job: nil, args: nil, at: nil, queue: nil)
|
|
325
326
|
original_performed_jobs_count = performed_jobs.count
|
|
326
327
|
expected = { job: job, args: args, at: at, queue: queue }.compact
|
|
327
|
-
|
|
328
|
+
expected_args = prepare_args_for_assertion(expected)
|
|
328
329
|
perform_enqueued_jobs { yield }
|
|
329
330
|
in_block_jobs = performed_jobs.drop(original_performed_jobs_count)
|
|
330
331
|
matching_job = in_block_jobs.find do |in_block_job|
|
|
331
|
-
|
|
332
|
+
deserialized_job = deserialize_args_for_assertion(in_block_job)
|
|
333
|
+
expected_args.all? { |key, value| value == deserialized_job[key] }
|
|
332
334
|
end
|
|
333
335
|
assert matching_job, "No performed job found with #{expected}"
|
|
334
336
|
instantiate_job(matching_job)
|
|
@@ -420,15 +422,21 @@ module ActiveJob
|
|
|
420
422
|
end
|
|
421
423
|
end
|
|
422
424
|
|
|
423
|
-
def
|
|
424
|
-
args.dup.tap do |
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
def prepare_args_for_assertion(args)
|
|
426
|
+
args.dup.tap do |arguments|
|
|
427
|
+
arguments[:at] = arguments[:at].to_f if arguments[:at]
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
def deserialize_args_for_assertion(job)
|
|
432
|
+
job.dup.tap do |new_job|
|
|
433
|
+
new_job[:args] = ActiveJob::Arguments.deserialize(new_job[:args]) if new_job[:args]
|
|
427
434
|
end
|
|
428
435
|
end
|
|
429
436
|
|
|
430
437
|
def instantiate_job(payload)
|
|
431
|
-
|
|
438
|
+
args = ActiveJob::Arguments.deserialize(payload[:args])
|
|
439
|
+
job = payload[:job].new(*args)
|
|
432
440
|
job.scheduled_at = Time.at(payload[:at]) if payload.key?(:at)
|
|
433
441
|
job.queue_name = payload[:queue]
|
|
434
442
|
job
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activejob
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.2.
|
|
4
|
+
version: 5.2.2.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-11-
|
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 5.2.
|
|
19
|
+
version: 5.2.2.rc1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 5.2.
|
|
26
|
+
version: 5.2.2.rc1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: globalid
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,8 +86,8 @@ homepage: http://rubyonrails.org
|
|
|
86
86
|
licenses:
|
|
87
87
|
- MIT
|
|
88
88
|
metadata:
|
|
89
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.
|
|
90
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.
|
|
89
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.2.rc1/activejob
|
|
90
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.2.rc1/activejob/CHANGELOG.md
|
|
91
91
|
post_install_message:
|
|
92
92
|
rdoc_options: []
|
|
93
93
|
require_paths:
|
|
@@ -99,9 +99,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
99
99
|
version: 2.2.2
|
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
requirements:
|
|
102
|
-
- - "
|
|
102
|
+
- - ">"
|
|
103
103
|
- !ruby/object:Gem::Version
|
|
104
|
-
version:
|
|
104
|
+
version: 1.3.1
|
|
105
105
|
requirements: []
|
|
106
106
|
rubyforge_project:
|
|
107
107
|
rubygems_version: 2.7.6
|