activejob 6.0.2.1 → 6.0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a84141030402e93cdfb87e098a434e1dc993c5fd6bc014301f1a982cd8d8cdc
4
- data.tar.gz: 1734e7ea70ee94ee85c5311e68eff1c77f3543669df85058fa6f43e434d814c9
3
+ metadata.gz: 5aa67f26abfc254d6855b0067f396a253241fdc74df407f4261d3dacb7235c48
4
+ data.tar.gz: d42e8410e3aaabd94cc68fb3ca300fd30a5a0ed2806be1ffcb036f1accd62c9a
5
5
  SHA512:
6
- metadata.gz: 4ebbb635e745dc22e2e971e32659f90d8ad588661f6e0002b366c806b7ac6f15fb2385227da06803717f1cf900bc716b3541532739f6206ed93a54112107a41b
7
- data.tar.gz: 4b3fc2ddf4d80af2b3acb54863944f85c7dcee77c8fe8f772a70073296a546b3995691b5f151623c94f666a5d2fbdb61190a049d9f6de6ca38a9eca06b3ea037
6
+ metadata.gz: 2d9937f4a3f5c0a3b062f2f6ad4db4db30ce9893c4423f2e49c7fedcb8ecd01fa101e1ee36dcbe670d2538bc440f8bd83dc4bfb3114515bd84d3d68202211ae2
7
+ data.tar.gz: 02baf8feb8d09b07c190ff90c40d40d880ad6eed7ecd672fff080910839ea5139a4f5deaeb2006b0f5269cda5d587e5cf9b7890e368e4d43f0e30b7c267516c7
@@ -1,3 +1,30 @@
1
+ ## Rails 6.0.3.2 (June 17, 2020) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.0.3.1 (May 18, 2020) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 6.0.3 (May 06, 2020) ##
12
+
13
+ * While using `perform_enqueued_jobs` test helper enqueued jobs must be stored for the later check with
14
+ `assert_enqueued_with`.
15
+
16
+ *Dmitry Polushkin*
17
+
18
+ * Add queue name support to Que adapter
19
+
20
+ *Brad Nauta*, *Wojciech Wnętrzak*
21
+
22
+
23
+ ## Rails 6.0.2.2 (March 19, 2020) ##
24
+
25
+ * No changes.
26
+
27
+
1
28
  ## Rails 6.0.2.1 (December 18, 2019) ##
2
29
 
3
30
  * No changes.
data/README.md CHANGED
@@ -130,4 +130,4 @@ Bug reports for the Ruby on Rails project can be filed here:
130
130
 
131
131
  Feature requests should be discussed on the rails-core mailing list here:
132
132
 
133
- * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
133
+ * https://discuss.rubyonrails.org/c/rubyonrails-core
@@ -45,7 +45,6 @@ module ActiveJob
45
45
  end
46
46
 
47
47
  private
48
-
49
48
  # :nodoc:
50
49
  PERMITTED_TYPES = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
51
50
  # :nodoc:
@@ -53,6 +52,8 @@ module ActiveJob
53
52
  # :nodoc:
54
53
  SYMBOL_KEYS_KEY = "_aj_symbol_keys"
55
54
  # :nodoc:
55
+ RUBY2_KEYWORDS_KEY = "_aj_ruby2_keywords"
56
+ # :nodoc:
56
57
  WITH_INDIFFERENT_ACCESS_KEY = "_aj_hash_with_indifferent_access"
57
58
  # :nodoc:
58
59
  OBJECT_SERIALIZER_KEY = "_aj_serialized"
@@ -61,10 +62,39 @@ module ActiveJob
61
62
  RESERVED_KEYS = [
62
63
  GLOBALID_KEY, GLOBALID_KEY.to_sym,
63
64
  SYMBOL_KEYS_KEY, SYMBOL_KEYS_KEY.to_sym,
65
+ RUBY2_KEYWORDS_KEY, RUBY2_KEYWORDS_KEY.to_sym,
64
66
  OBJECT_SERIALIZER_KEY, OBJECT_SERIALIZER_KEY.to_sym,
65
67
  WITH_INDIFFERENT_ACCESS_KEY, WITH_INDIFFERENT_ACCESS_KEY.to_sym,
66
68
  ]
67
- private_constant :PERMITTED_TYPES, :RESERVED_KEYS, :GLOBALID_KEY, :SYMBOL_KEYS_KEY, :WITH_INDIFFERENT_ACCESS_KEY
69
+ private_constant :PERMITTED_TYPES, :RESERVED_KEYS, :GLOBALID_KEY,
70
+ :SYMBOL_KEYS_KEY, :RUBY2_KEYWORDS_KEY, :WITH_INDIFFERENT_ACCESS_KEY
71
+
72
+ unless Hash.respond_to?(:ruby2_keywords_hash?) && Hash.respond_to?(:ruby2_keywords_hash)
73
+ using Module.new {
74
+ refine Hash do
75
+ class << Hash
76
+ if RUBY_VERSION >= "2.7"
77
+ def ruby2_keywords_hash?(hash)
78
+ !new(*[hash]).default.equal?(hash)
79
+ end
80
+ else
81
+ def ruby2_keywords_hash?(hash)
82
+ false
83
+ end
84
+ end
85
+
86
+ def ruby2_keywords_hash(hash)
87
+ _ruby2_keywords_hash(**hash)
88
+ end
89
+
90
+ private def _ruby2_keywords_hash(*args)
91
+ args.last
92
+ end
93
+ ruby2_keywords(:_ruby2_keywords_hash) if respond_to?(:ruby2_keywords, true)
94
+ end
95
+ end
96
+ }
97
+ end
68
98
 
69
99
  def serialize_argument(argument)
70
100
  case argument
@@ -77,9 +107,14 @@ module ActiveJob
77
107
  when ActiveSupport::HashWithIndifferentAccess
78
108
  serialize_indifferent_hash(argument)
79
109
  when Hash
80
- symbol_keys = argument.each_key.grep(Symbol).map(&:to_s)
110
+ symbol_keys = argument.each_key.grep(Symbol).map!(&:to_s)
111
+ aj_hash_key = if Hash.ruby2_keywords_hash?(argument)
112
+ RUBY2_KEYWORDS_KEY
113
+ else
114
+ SYMBOL_KEYS_KEY
115
+ end
81
116
  result = serialize_hash(argument)
82
- result[SYMBOL_KEYS_KEY] = symbol_keys
117
+ result[aj_hash_key] = symbol_keys
83
118
  result
84
119
  when -> (arg) { arg.respond_to?(:permitted?) }
85
120
  serialize_indifferent_hash(argument.to_h)
@@ -133,6 +168,9 @@ module ActiveJob
133
168
  result = result.with_indifferent_access
134
169
  elsif symbol_keys = result.delete(SYMBOL_KEYS_KEY)
135
170
  result = transform_symbol_keys(result, symbol_keys)
171
+ elsif symbol_keys = result.delete(RUBY2_KEYWORDS_KEY)
172
+ result = transform_symbol_keys(result, symbol_keys)
173
+ result = Hash.ruby2_keywords_hash(result)
136
174
  end
137
175
  result
138
176
  end
@@ -10,9 +10,11 @@ module ActiveJob
10
10
  def perform_now(*args)
11
11
  @job_class.new(*args).perform_now
12
12
  end
13
+ ruby2_keywords(:perform_now) if respond_to?(:ruby2_keywords, true)
13
14
 
14
15
  def perform_later(*args)
15
16
  @job_class.new(*args).enqueue @options
16
17
  end
18
+ ruby2_keywords(:perform_later) if respond_to?(:ruby2_keywords, true)
17
19
  end
18
20
  end
@@ -86,6 +86,7 @@ module ActiveJob
86
86
  @executions = 0
87
87
  @exception_executions = {}
88
88
  end
89
+ ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
89
90
 
90
91
  # Returns a hash with the job data that can safely be passed to the
91
92
  # queuing adapter.
@@ -21,11 +21,13 @@ module ActiveJob
21
21
  def perform_later(*args)
22
22
  job_or_instantiate(*args).enqueue
23
23
  end
24
+ ruby2_keywords(:perform_later) if respond_to?(:ruby2_keywords, true)
24
25
 
25
26
  private
26
27
  def job_or_instantiate(*args) # :doc:
27
28
  args.first.is_a?(self) ? args.first : new(*args)
28
29
  end
30
+ ruby2_keywords(:job_or_instantiate) if respond_to?(:ruby2_keywords, true)
29
31
  end
30
32
 
31
33
  # Enqueues the job to be performed by the queue adapter.
@@ -115,7 +115,7 @@ module ActiveJob
115
115
  # end
116
116
  # end
117
117
  def retry_job(options = {})
118
- instrument :enqueue_retry, options.slice(:error, :wait) do
118
+ instrument :enqueue_retry, **options.slice(:error, :wait) do
119
119
  enqueue options
120
120
  end
121
121
  end
@@ -17,6 +17,7 @@ module ActiveJob
17
17
  def perform_now(*args)
18
18
  job_or_instantiate(*args).perform_now
19
19
  end
20
+ ruby2_keywords(:perform_now) if respond_to?(:ruby2_keywords, true)
20
21
 
21
22
  def execute(job_data) #:nodoc:
22
23
  ActiveJob::Callbacks.run_callbacks(:execute) do
@@ -9,8 +9,8 @@ module ActiveJob
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
- TINY = 2
13
- PRE = "1"
12
+ TINY = 3
13
+ PRE = "2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -18,13 +18,13 @@ module ActiveJob
18
18
  # Rails.application.config.active_job.queue_adapter = :que
19
19
  class QueAdapter
20
20
  def enqueue(job) #:nodoc:
21
- que_job = JobWrapper.enqueue job.serialize, priority: job.priority
21
+ que_job = JobWrapper.enqueue job.serialize, priority: job.priority, queue: job.queue_name
22
22
  job.provider_job_id = que_job.attrs["job_id"]
23
23
  que_job
24
24
  end
25
25
 
26
26
  def enqueue_at(job, timestamp) #:nodoc:
27
- que_job = JobWrapper.enqueue job.serialize, priority: job.priority, run_at: Time.at(timestamp)
27
+ que_job = JobWrapper.enqueue job.serialize, priority: job.priority, queue: job.queue_name, run_at: Time.at(timestamp)
28
28
  job.provider_job_id = que_job.attrs["job_id"]
29
29
  que_job
30
30
  end
@@ -26,28 +26,28 @@ module ActiveJob
26
26
  end
27
27
 
28
28
  def enqueue(job) #:nodoc:
29
- return if filtered?(job)
30
-
31
29
  job_data = job_to_hash(job)
32
- perform_or_enqueue(perform_enqueued_jobs, job, job_data)
30
+ perform_or_enqueue(perform_enqueued_jobs && !filtered?(job), job, job_data)
33
31
  end
34
32
 
35
33
  def enqueue_at(job, timestamp) #:nodoc:
36
- return if filtered?(job)
37
-
38
34
  job_data = job_to_hash(job, at: timestamp)
39
- perform_or_enqueue(perform_enqueued_at_jobs, job, job_data)
35
+ perform_or_enqueue(perform_enqueued_at_jobs && !filtered?(job), job, job_data)
40
36
  end
41
37
 
42
38
  private
43
39
  def job_to_hash(job, extras = {})
44
- { job: job.class, args: job.serialize.fetch("arguments"), queue: job.queue_name }.merge!(extras)
40
+ job.serialize.tap do |job_data|
41
+ job_data[:job] = job.class
42
+ job_data[:args] = job_data.fetch("arguments")
43
+ job_data[:queue] = job_data.fetch("queue_name")
44
+ end.merge(extras)
45
45
  end
46
46
 
47
47
  def perform_or_enqueue(perform, job, job_data)
48
48
  if perform
49
49
  performed_jobs << job_data
50
- Base.execute job.serialize
50
+ Base.execute(job.serialize)
51
51
  else
52
52
  enqueued_jobs << job_data
53
53
  end
@@ -12,7 +12,6 @@ module ActiveJob
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def klass
17
16
  Date
18
17
  end
@@ -12,7 +12,6 @@ module ActiveJob
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def klass
17
16
  DateTime
18
17
  end
@@ -15,7 +15,6 @@ module ActiveJob
15
15
  end
16
16
 
17
17
  private
18
-
19
18
  def klass
20
19
  ActiveSupport::Duration
21
20
  end
@@ -44,7 +44,6 @@ module ActiveJob
44
44
  end
45
45
 
46
46
  private
47
-
48
47
  # The class of the object that will be serialized.
49
48
  def klass # :doc:
50
49
  raise NotImplementedError
@@ -12,7 +12,6 @@ module ActiveJob
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def klass
17
16
  Symbol
18
17
  end
@@ -12,7 +12,6 @@ module ActiveJob
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def klass
17
16
  Time
18
17
  end
@@ -12,7 +12,6 @@ module ActiveJob
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def klass
17
16
  ActiveSupport::TimeWithZone
18
17
  end
@@ -351,9 +351,21 @@ module ActiveJob
351
351
  # assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon)
352
352
  # end
353
353
  #
354
+ # The +at+ and +args+ arguments also accept a proc.
354
355
  #
355
- # The +args+ argument also accepts a proc which will get passed the actual
356
- # job's arguments. Your proc needs to return a boolean value determining if
356
+ # To the +at+ proc, it will get passed the actual job's at argument.
357
+ #
358
+ # def test_assert_enqueued_with
359
+ # expected_time = ->(at) do
360
+ # (Date.yesterday..Date.tomorrow).cover?(at)
361
+ # end
362
+ #
363
+ # MyJob.set(at: Date.today.noon).perform_later
364
+ # assert_enqueued_with(job: MyJob, at: expected_time)
365
+ # end
366
+ #
367
+ # To the +args+ proc, it will get passed the actual job's arguments
368
+ # Your proc needs to return a boolean value determining if
357
369
  # the job's arguments matches your expectation. This is useful to check only
358
370
  # for a subset of arguments.
359
371
  #
@@ -366,7 +378,6 @@ module ActiveJob
366
378
  # assert_enqueued_with(job: MyJob, args: expected_args, queue: 'low')
367
379
  # end
368
380
  #
369
- #
370
381
  # If a block is passed, asserts that the block will cause the job to be
371
382
  # enqueued with the given arguments.
372
383
  #
@@ -425,8 +436,21 @@ module ActiveJob
425
436
  # assert_performed_with(job: MyJob, at: Date.tomorrow.noon)
426
437
  # end
427
438
  #
428
- # The +args+ argument also accepts a proc which will get passed the actual
429
- # job's arguments. Your proc needs to return a boolean value determining if
439
+ # The +at+ and +args+ arguments also accept a proc.
440
+ #
441
+ # To the +at+ proc, it will get passed the actual job's at argument.
442
+ #
443
+ # def test_assert_enqueued_with
444
+ # expected_time = ->(at) do
445
+ # (Date.yesterday..Date.tomorrow).cover?(at)
446
+ # end
447
+ #
448
+ # MyJob.set(at: Date.today.noon).perform_later
449
+ # assert_enqueued_with(job: MyJob, at: expected_time)
450
+ # end
451
+ #
452
+ # To the +args+ proc, it will get passed the actual job's arguments
453
+ # Your proc needs to return a boolean value determining if
430
454
  # the job's arguments matches your expectation. This is useful to check only
431
455
  # for a subset of arguments.
432
456
  #
@@ -630,7 +654,10 @@ module ActiveJob
630
654
 
631
655
  def prepare_args_for_assertion(args)
632
656
  args.dup.tap do |arguments|
633
- arguments[:at] = round_time_arguments(arguments[:at]) if arguments[:at]
657
+ if arguments[:at] && !arguments[:at].respond_to?(:call)
658
+ at_range = arguments[:at] - 1..arguments[:at] + 1
659
+ arguments[:at] = ->(at) { at_range.cover?(at) }
660
+ end
634
661
  arguments[:args] = round_time_arguments(arguments[:args]) if arguments[:args]
635
662
  end
636
663
  end
@@ -650,16 +677,15 @@ module ActiveJob
650
677
 
651
678
  def deserialize_args_for_assertion(job)
652
679
  job.dup.tap do |new_job|
653
- new_job[:at] = round_time_arguments(Time.at(new_job[:at])) if new_job[:at]
680
+ new_job[:at] = Time.at(new_job[:at]) if new_job[:at]
654
681
  new_job[:args] = ActiveJob::Arguments.deserialize(new_job[:args]) if new_job[:args]
655
682
  end
656
683
  end
657
684
 
658
685
  def instantiate_job(payload)
659
- args = ActiveJob::Arguments.deserialize(payload[:args])
660
- job = payload[:job].new(*args)
686
+ job = payload[:job].deserialize(payload)
661
687
  job.scheduled_at = Time.at(payload[:at]) if payload.key?(:at)
662
- job.queue_name = payload[:queue]
688
+ job.send(:deserialize_arguments_if_needed)
663
689
  job
664
690
  end
665
691
 
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: 6.0.2.1
4
+ version: 6.0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-18 00:00:00.000000000 Z
11
+ date: 2020-06-17 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: 6.0.2.1
19
+ version: 6.0.3.2
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: 6.0.2.1
26
+ version: 6.0.3.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: globalid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,11 +95,11 @@ licenses:
95
95
  - MIT
96
96
  metadata:
97
97
  bug_tracker_uri: https://github.com/rails/rails/issues
98
- changelog_uri: https://github.com/rails/rails/blob/v6.0.2.1/activejob/CHANGELOG.md
99
- documentation_uri: https://api.rubyonrails.org/v6.0.2.1/
100
- mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
101
- source_code_uri: https://github.com/rails/rails/tree/v6.0.2.1/activejob
102
- post_install_message:
98
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.3.2/activejob/CHANGELOG.md
99
+ documentation_uri: https://api.rubyonrails.org/v6.0.3.2/
100
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
101
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.3.2/activejob
102
+ post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
105
105
  - lib
@@ -114,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.0.3
118
- signing_key:
117
+ rubygems_version: 3.1.2
118
+ signing_key:
119
119
  specification_version: 4
120
120
  summary: Job framework with pluggable queues.
121
121
  test_files: []