activejob 6.0.2.2 → 6.0.3.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59defc07bc7739ed26d358406f96ede0a8737198da0440c2673e73012d0a217a
4
- data.tar.gz: e247580a7cfcfb77c6489ed4de534bda2aaf340354c546a1f0b8f50cecdbc28e
3
+ metadata.gz: b5f5eec4ecd6c8a74c23a1def2d7721d5d4373ddc3fb54f3d51cc2f5d041c2ba
4
+ data.tar.gz: e0a6670180a0f3d99e5c68645ff2fb88bdca5bc216a87f7c8c2ec502bab91b8b
5
5
  SHA512:
6
- metadata.gz: cae6e8017199f92a53b539e1cff49fb694d2835850ba55d4410f90621684c7bf8f968ac7c634f0e316d90a869d25c1524d89a76a21945184b797d3be7ec59cbf
7
- data.tar.gz: c2df4ebd7f33e8ab05b0a4628fa51f6b9766c91da4b3e7bee1b3ffc6ca3882753f46e4c9e80cc79cdaecaa5f6654a6d949e40253cdfed4b1d8390b1600afc627
6
+ metadata.gz: a0038ef9bdb847508829f59320cb4e80cb35c1089e46e12765c8d6f19be5b45c9049b7fd7e24cf85318f2c32d1839d75a7b13c48712417a140139b72b42c566d
7
+ data.tar.gz: 90be65d1d2ec6cee70d7aed484e842242d5c38fdc042fea6661399f480973de206cad81a7482e06bf62453272185c4ef6f193b187ca8f65ae25bb917a8766af3
@@ -1,3 +1,20 @@
1
+ ## Rails 6.0.3.rc1 (April 30, 2020) ##
2
+
3
+ * While using `perform_enqueued_jobs` test helper enqueued jobs must be stored for the later check with
4
+ `assert_enqueued_with`.
5
+
6
+ *Dmitry Polushkin*
7
+
8
+ * Add queue name support to Que adapter
9
+
10
+ *Brad Nauta*, *Wojciech Wnętrzak*
11
+
12
+
13
+ ## Rails 6.0.2.2 (March 19, 2020) ##
14
+
15
+ * No changes.
16
+
17
+
1
18
  ## Rails 6.0.2.1 (December 18, 2019) ##
2
19
 
3
20
  * 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 = "2"
12
+ TINY = 3
13
+ PRE = "rc1"
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.2
4
+ version: 6.0.3.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: 2020-03-19 00:00:00.000000000 Z
11
+ date: 2020-05-01 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.2
19
+ version: 6.0.3.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: 6.0.2.2
26
+ version: 6.0.3.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: globalid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,10 +95,10 @@ 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.2/activejob/CHANGELOG.md
99
- documentation_uri: https://api.rubyonrails.org/v6.0.2.2/
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.2/activejob
98
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.3.rc1/activejob/CHANGELOG.md
99
+ documentation_uri: https://api.rubyonrails.org/v6.0.3.rc1/
100
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
101
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.3.rc1/activejob
102
102
  post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
@@ -110,11 +110,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: 2.5.0
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">="
113
+ - - ">"
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: 1.3.1
116
116
  requirements: []
117
- rubygems_version: 3.0.3
117
+ rubygems_version: 3.1.2
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Job framework with pluggable queues.