diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8505604..7e47079 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: - gemfiles/rails_6_1.gemfile - gemfiles/rails_7_0.gemfile - gemfiles/rails_7_1.gemfile + - gemfiles/rails_7_2.gemfile exclude: - ruby: '3.2' gemfile: gemfiles/rails_5_2.gemfile diff --git a/Appraisals b/Appraisals index f6ba35c..f43f3e3 100644 --- a/Appraisals +++ b/Appraisals @@ -28,6 +28,12 @@ appraise 'rails-7-1' do gem 'activerecord', '~> 7.1.0' end +appraise 'rails-7-2' do + gem 'actionmailer', '~> 7.2.0' + gem 'activejob', '~> 7.2.0' + gem 'activerecord', '~> 7.2.0' +end + appraise 'rails-main' do gem 'actionmailer', github: 'rails/rails', glob: 'actionmailer/*.gemspec' gem 'activejob', github: 'rails/rails', glob: 'activejob/*.gemspec' diff --git a/delayed.gemspec b/delayed.gemspec index 97c39ae..866141f 100644 --- a/delayed.gemspec +++ b/delayed.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.summary = 'a multi-threaded, SQL-driven ActiveJob backend used at Betterment to process millions of background jobs per day' - spec.version = '0.5.4' + spec.version = '0.5.5' spec.metadata = { 'changelog_uri' => 'https://github.com/betterment/delayed/blob/main/CHANGELOG.md', 'bug_tracker_uri' => 'https://github.com/betterment/delayed/issues', diff --git a/gemfiles/rails_7_2.gemfile b/gemfiles/rails_7_2.gemfile new file mode 100644 index 0000000..a411d98 --- /dev/null +++ b/gemfiles/rails_7_2.gemfile @@ -0,0 +1,18 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "actionmailer", "~> 7.2.0" +gem "activejob", "~> 7.2.0" +gem "activerecord", "~> 7.2.0" +gem "appraisal" +gem "betterlint" +gem "mysql2" +gem "pg" +gem "rake" +gem "rspec" +gem "sqlite3", "~> 1.7.3" +gem "timecop" +gem "zeitwerk" + +gemspec path: "../" diff --git a/lib/delayed/active_job_adapter.rb b/lib/delayed/active_job_adapter.rb index ffafe6b..bbaf8a0 100644 --- a/lib/delayed/active_job_adapter.rb +++ b/lib/delayed/active_job_adapter.rb @@ -17,7 +17,7 @@ def enqueue_at(job, timestamp) private def _enqueue(job, opts = {}) - if job.class.respond_to?(:enqueue_after_transaction_commit) && job.class.enqueue_after_transaction_commit + if job.class.respond_to?(:enqueue_after_transaction_commit) && job.class.enqueue_after_transaction_commit == :always raise UnsafeEnqueueError, "The ':delayed' ActiveJob adapter is not compatible with enqueue_after_transaction_commit" end diff --git a/spec/delayed/active_job_adapter_spec.rb b/spec/delayed/active_job_adapter_spec.rb index 402ee20..5e18843 100644 --- a/spec/delayed/active_job_adapter_spec.rb +++ b/spec/delayed/active_job_adapter_spec.rb @@ -288,16 +288,27 @@ def perform(arg, kwarg:) end if ActiveJob.gem_version.release >= Gem::Version.new('7.2') - context 'when the given job sets enqueue_after_transaction_commit to true' do + context 'when the given job sets enqueue_after_transaction_commit to :always' do before do JobClass.include ActiveJob::EnqueueAfterTransactionCommit # normally run in an ActiveJob railtie - JobClass.enqueue_after_transaction_commit = true + JobClass.enqueue_after_transaction_commit = :always end it 'raises an exception on enqueue' do expect { JobClass.perform_later }.to raise_error(Delayed::ActiveJobAdapter::UnsafeEnqueueError) end end + + context 'when the given job sets enqueue_after_transaction_commit to :never' do + before do + JobClass.include ActiveJob::EnqueueAfterTransactionCommit # normally run in an ActiveJob railtie + JobClass.enqueue_after_transaction_commit = :never + end + + it 'does not raises an exception on enqueue' do + expect { JobClass.perform_later }.not_to raise_error(Delayed::ActiveJobAdapter::UnsafeEnqueueError) + end + end end context 'when using the ActiveJob test adapter' do