From b714be6f4ad34a643604c54196d9710b28f58b6f Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:59:21 +0200 Subject: [PATCH] Allow `GoodJob::Job#retry_job`'s transaction to be joinable (fix CI for current `rails-head`) (#1496) * Fix CI for current `rails-head` It is now >= 3.2 only * Remove `joinable: false, requires_new: true` options from `Job#retry_job` --------- Co-authored-by: Ben Sheldon [he/him] --- Appraisals | 13 ++++++++----- app/models/good_job/job.rb | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Appraisals b/Appraisals index e9be7e73..c9c26ea5 100644 --- a/Appraisals +++ b/Appraisals @@ -2,6 +2,7 @@ ruby_30_or_higher = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0') ruby_31_or_higher = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1') +ruby_32_or_higher = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2') jruby = RUBY_PLATFORM.include?('java') unless ruby_31_or_higher # https://github.com/rails/rails/issues/44090#issuecomment-1007686519 @@ -38,11 +39,13 @@ if ruby_31_or_higher gem "rails", "~> 7.2.0.a" gem "selenium-webdriver", "~> 4.0" # https://github.com/rails/rails/pull/43498 end + end +end - appraise "rails-head" do - gem "capybara", "~> 3.36" # For Ruby 3.1 support https://github.com/teamcapybara/capybara/pull/24 - gem "rails", github: "rails/rails", branch: "main" - gem "selenium-webdriver", "~> 4.0" # https://github.com/rails/rails/pull/43498 - end +if ruby_32_or_higher && !jruby + appraise "rails-head" do + gem "capybara", "~> 3.36" # For Ruby 3.1 support https://github.com/teamcapybara/capybara/pull/24 + gem "rails", github: "rails/rails", branch: "main" + gem "selenium-webdriver", "~> 4.0" # https://github.com/rails/rails/pull/43498 end end diff --git a/app/models/good_job/job.rb b/app/models/good_job/job.rb index 8bbfebb8..063d1f5c 100644 --- a/app/models/good_job/job.rb +++ b/app/models/good_job/job.rb @@ -478,7 +478,7 @@ def retry_job current_thread.job = self current_thread.retry_now = true - self.class.transaction(joinable: false, requires_new: true) do + transaction do new_active_job = active_job.retry_job(wait: 0, error: error) self.error_event = :retried if error save!