delayed 0.6.0 → 0.7.1

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: 6e71f18ed659d830765786daba4513f7cedfef9fb645055cd01e95af8be066b3
4
- data.tar.gz: c3b0624ab16f81e2aa7e4296a56a4967e88e75659eca20078ad662c0cc7d37ec
3
+ metadata.gz: 223856c2ccfb73e2f42eed3da86e70b0a819a575028ca1d0ddbebe0fc757c1d6
4
+ data.tar.gz: b8d496dbd42774fcb7a5528cb4969b15a87cebd2c59899ad8dafa86438279874
5
5
  SHA512:
6
- metadata.gz: b94b8a054612a71dc72078a0b62abf5db8a9bb305515ac75e2baeb39ab12d188eea4c168f3e774b3beebb608c821e808e2c24164a68fbdaebf894c7a566ec69e
7
- data.tar.gz: f46b3769bc15ac507442548b1b9e810d0e70ae68a4a89eb29732c1c1b325d307eed593ab7ee49a78d6296bf69440ceb221ddb1e25e4b3237e5a723595c2903ed
6
+ metadata.gz: 5770b2945b0ff2e2a5f80a5cad81c8dd506c41519897e19ad29f973b57250891f3aa31c2d57135f69c960de12ea0724ad4bfa2bc68f445be6699851177a67b5e
7
+ data.tar.gz: 89dbae3fb440d8cef88ed57131131ca7d3081b8039f772b6d88ebbd09332f7ffa9a2cfe09e5505d5c422ce69b82ae8344bf79d475022aa454594e87ef559e1d6
@@ -17,7 +17,7 @@ module Delayed
17
17
  private
18
18
 
19
19
  def _enqueue(job, opts = {})
20
- if job.class.respond_to?(:enqueue_after_transaction_commit) && job.class.enqueue_after_transaction_commit == :always
20
+ if enqueue_after_transaction_commit_enabled?(job)
21
21
  raise UnsafeEnqueueError, "The ':delayed' ActiveJob adapter is not compatible with enqueue_after_transaction_commit"
22
22
  end
23
23
 
@@ -29,6 +29,11 @@ module Delayed
29
29
  end
30
30
  end
31
31
 
32
+ def enqueue_after_transaction_commit_enabled?(job)
33
+ job.class.respond_to?(:enqueue_after_transaction_commit) &&
34
+ [true, :always].include?(job.class.enqueue_after_transaction_commit)
35
+ end
36
+
32
37
  module EnqueuingPatch
33
38
  def self.included(klass)
34
39
  klass.prepend PrependedMethods
@@ -1,7 +1,8 @@
1
- require 'active_support/proxy_object'
2
-
3
1
  module Delayed
4
- class DelayProxy < ActiveSupport::ProxyObject
2
+ class DelayProxy < BasicObject
3
+ undef_method :==
4
+ undef_method :equal?
5
+
5
6
  def initialize(payload_class, target, options)
6
7
  @payload_class = payload_class
7
8
  @target = target
@@ -49,11 +49,11 @@ RSpec.describe Delayed::ActiveJobAdapter do
49
49
  / priority: ?\n/,
50
50
  " arguments: []\n",
51
51
  " executions: 0\n",
52
- (" exception_executions: {}\n" if ActiveJob::VERSION::MAJOR >= 6),
52
+ (" exception_executions: {}\n" if ActiveJob.gem_version >= Gem::Version.new('6.0')),
53
53
  " locale: en\n",
54
- (/ timezone: ?\n/ if ActiveJob::VERSION::MAJOR >= 6),
55
- (/ enqueued_at: '2023-01-20T18:52:29(\.\d+)?Z'\n/ if ActiveJob::VERSION::MAJOR >= 6),
56
- (/ scheduled_at: ?\n/ if ActiveJob::VERSION::MAJOR >= 7 && ActiveJob::VERSION::MINOR >= 1),
54
+ (/ timezone: ?\n/ if ActiveJob.gem_version >= Gem::Version.new('6.0')),
55
+ (/ enqueued_at: '2023-01-20T18:52:29(\.\d+)?Z'\n/ if ActiveJob.gem_version >= Gem::Version.new('6.0')),
56
+ (/ scheduled_at: ?\n/ if ActiveJob.gem_version >= Gem::Version.new('7.1')),
57
57
  ].compact
58
58
  end
59
59
  end
@@ -295,7 +295,9 @@ RSpec.describe Delayed::ActiveJobAdapter do
295
295
  end
296
296
 
297
297
  it 'raises an exception on enqueue' do
298
- expect { JobClass.perform_later }.to raise_error(Delayed::ActiveJobAdapter::UnsafeEnqueueError)
298
+ ActiveJob.deprecator.silence do
299
+ expect { JobClass.perform_later }.to raise_error(Delayed::ActiveJobAdapter::UnsafeEnqueueError)
300
+ end
299
301
  end
300
302
  end
301
303
 
@@ -306,7 +308,33 @@ RSpec.describe Delayed::ActiveJobAdapter do
306
308
  end
307
309
 
308
310
  it 'does not raises an exception on enqueue' do
309
- expect { JobClass.perform_later }.not_to raise_error(Delayed::ActiveJobAdapter::UnsafeEnqueueError)
311
+ ActiveJob.deprecator.silence do
312
+ expect { JobClass.perform_later }.not_to raise_error
313
+ end
314
+ end
315
+ end
316
+ end
317
+
318
+ if ActiveJob.gem_version.release >= Gem::Version.new('8.0')
319
+ context 'when the given job sets enqueue_after_transaction_commit to true' do
320
+ before do
321
+ JobClass.include ActiveJob::EnqueueAfterTransactionCommit # normally run in an ActiveJob railtie
322
+ JobClass.enqueue_after_transaction_commit = true
323
+ end
324
+
325
+ it 'raises an exception on enqueue' do
326
+ expect { JobClass.perform_later }.to raise_error(Delayed::ActiveJobAdapter::UnsafeEnqueueError)
327
+ end
328
+ end
329
+
330
+ context 'when the given job sets enqueue_after_transaction_commit to false' do
331
+ before do
332
+ JobClass.include ActiveJob::EnqueueAfterTransactionCommit # normally run in an ActiveJob railtie
333
+ JobClass.enqueue_after_transaction_commit = false
334
+ end
335
+
336
+ it 'does not raises an exception on enqueue' do
337
+ expect { JobClass.perform_later }.not_to raise_error
310
338
  end
311
339
  end
312
340
  end
data/spec/helper.rb CHANGED
@@ -10,6 +10,13 @@ require 'sample_jobs'
10
10
 
11
11
  require 'rake'
12
12
 
13
+ if ActiveSupport.gem_version >= Gem::Version.new('7.1')
14
+ frameworks = [ActiveModel, ActiveRecord, ActionMailer, ActiveJob, ActiveSupport]
15
+ frameworks.each { |framework| framework.deprecator.behavior = :raise }
16
+ else
17
+ ActiveSupport::Deprecation.behavior = :raise
18
+ end
19
+
13
20
  if ENV['DEBUG_LOGS']
14
21
  Delayed.logger = Logger.new($stdout)
15
22
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Griffith
@@ -16,10 +16,9 @@ authors:
16
16
  - Matt Griffin
17
17
  - Steve Richert
18
18
  - Tobias Lütke
19
- autorequire:
20
19
  bindir: bin
21
20
  cert_chain: []
22
- date: 2024-12-18 00:00:00.000000000 Z
21
+ date: 2025-01-24 00:00:00.000000000 Z
23
22
  dependencies:
24
23
  - !ruby/object:Gem::Dependency
25
24
  name: activerecord
@@ -124,7 +123,6 @@ metadata:
124
123
  bug_tracker_uri: https://github.com/betterment/delayed/issues
125
124
  source_code_uri: https://github.com/betterment/delayed
126
125
  rubygems_mfa_required: 'true'
127
- post_install_message:
128
126
  rdoc_options: []
129
127
  require_paths:
130
128
  - lib
@@ -139,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
137
  - !ruby/object:Gem::Version
140
138
  version: '0'
141
139
  requirements: []
142
- rubygems_version: 3.3.26
143
- signing_key:
140
+ rubygems_version: 3.6.2
144
141
  specification_version: 4
145
142
  summary: a multi-threaded, SQL-driven ActiveJob backend used at Betterment to process
146
143
  millions of background jobs per day