From 03a26c160336b273640dde73e170d3d08b28b17a Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Fri, 24 Jun 2022 16:12:02 -0700 Subject: [PATCH] Remove support for EOL Rails 5.2 --- .rubocop.yml | 2 +- Appraisals | 7 ---- Gemfile.lock | 6 +-- .../layouts/good_job/application.html.erb | 2 +- gemfiles/rails_5.2.gemfile | 29 ------------- good_job.gemspec | 6 +-- lib/good_job/current_thread.rb | 4 +- spec/lib/models/good_job/execution_spec.rb | 41 +++++++++---------- 8 files changed, 29 insertions(+), 68 deletions(-) delete mode 100644 gemfiles/rails_5.2.gemfile diff --git a/.rubocop.yml b/.rubocop.yml index 2de8436a0..239564665 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ inherit_mode: AllCops: TargetRubyVersion: 2.5 - TargetRailsVersion: 5.2 + TargetRailsVersion: 6.0 DisplayCopNames: true DisplayStyleGuide: true Include: diff --git a/Appraisals b/Appraisals index 14f8cc7e2..fc27430f2 100644 --- a/Appraisals +++ b/Appraisals @@ -1,15 +1,8 @@ # frozen_string_literal: true -ruby_2 = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3') ruby_27_or_higher = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7') ruby_31_or_higher = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1') jruby = RUBY_PLATFORM.include?('java') -if ruby_2 - appraise "rails-5.2" do - gem "rails", "~> 5.2.0" - end -end - unless ruby_31_or_higher # https://github.com/rails/rails/issues/44090#issuecomment-1007686519 appraise "rails-6.0" do gem "rails", "~> 6.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index 35dbb837a..f9704e01d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,11 +12,11 @@ PATH remote: . specs: good_job (2.99.0) - activejob (>= 5.2.0) - activerecord (>= 5.2.0) + activejob (>= 6.0.0) + activerecord (>= 6.0.0) concurrent-ruby (>= 1.0.2) fugit (>= 1.1) - railties (>= 5.2.0) + railties (>= 6.0.0) thor (>= 0.14.1) webrick (>= 1.3) zeitwerk (>= 2.0) diff --git a/app/views/layouts/good_job/application.html.erb b/app/views/layouts/good_job/application.html.erb index a4703752d..4911ae785 100644 --- a/app/views/layouts/good_job/application.html.erb +++ b/app/views/layouts/good_job/application.html.erb @@ -16,7 +16,7 @@ <%= tag.script "", src: rails_ujs_path(format: :js, v: GoodJob::VERSION, locale: nil), nonce: content_security_policy_nonce %> <%= tag.script "", src: es_module_shims_path(format: :js, v: GoodJob::VERSION, locale: nil), async: true, nonce: content_security_policy_nonce %> - <% importmaps = { imports: GoodJob::AssetsController.js_modules.keys.each_with_object({}) { |module_name, imports| imports[module_name] = modules_path(module_name, format: :js, locale: nil, v: GoodJob::VERSION) } } %> + <% importmaps = { imports: GoodJob::AssetsController.js_modules.keys.index_with { |module_name| modules_path(module_name, format: :js, locale: nil, v: GoodJob::VERSION) } } %> <%= tag.script importmaps.to_json.html_safe, type: "importmap", nonce: content_security_policy_nonce %> <%= tag.script "", src: scripts_path(format: :js, v: GoodJob::VERSION, locale: nil), type: "module", nonce: content_security_policy_nonce %> diff --git a/gemfiles/rails_5.2.gemfile b/gemfiles/rails_5.2.gemfile deleted file mode 100644 index 5ab936c8e..000000000 --- a/gemfiles/rails_5.2.gemfile +++ /dev/null @@ -1,29 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activerecord-jdbcpostgresql-adapter", platforms: [:jruby] -gem "appraisal", branch: "fix-bundle-env", git: "https://github.com/bensheldon/appraisal.git" -gem "nokogiri", "~> 1.12.0" -gem "pg", platforms: [:mri, :mingw, :x64_mingw] -gem "rails", "~> 5.2.0" - -platforms :ruby do - gem "activerecord-explain-analyze" - gem "memory_profiler" - gem "pry-byebug" - gem "rbtrace" - - group :lint do - gem "easy_translate" - gem "erb_lint", ">= 0.0.35" - gem "i18n-tasks" - gem "mdl" - gem "rubocop" - gem "rubocop-performance" - gem "rubocop-rails" - gem "rubocop-rspec" - end -end - -gemspec path: "../" diff --git a/good_job.gemspec b/good_job.gemspec index 48fb7d29e..9eae97934 100644 --- a/good_job.gemspec +++ b/good_job.gemspec @@ -50,11 +50,11 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.5.0" - spec.add_dependency "activejob", ">= 5.2.0" - spec.add_dependency "activerecord", ">= 5.2.0" + spec.add_dependency "activejob", ">= 6.0.0" + spec.add_dependency "activerecord", ">= 6.0.0" spec.add_dependency "concurrent-ruby", ">= 1.0.2" spec.add_dependency "fugit", ">= 1.1" - spec.add_dependency "railties", ">= 5.2.0" + spec.add_dependency "railties", ">= 6.0.0" spec.add_dependency "thor", ">= 0.14.1" spec.add_dependency "webrick", ">= 1.3" spec.add_dependency "zeitwerk", ">= 2.0" diff --git a/lib/good_job/current_thread.rb b/lib/good_job/current_thread.rb index 226812db7..4c3c22f4f 100644 --- a/lib/good_job/current_thread.rb +++ b/lib/good_job/current_thread.rb @@ -56,8 +56,8 @@ def self.reset(values = {}) # Exports values to hash # @return [Hash] def self.to_h - ACCESSORS.each_with_object({}) do |accessor, hash| - hash[accessor] = send(accessor) + ACCESSORS.index_with do |accessor| + send(accessor) end end diff --git a/spec/lib/models/good_job/execution_spec.rb b/spec/lib/models/good_job/execution_spec.rb index 9a2c2eedd..93919a444 100644 --- a/spec/lib/models/good_job/execution_spec.rb +++ b/spec/lib/models/good_job/execution_spec.rb @@ -289,32 +289,29 @@ def perform(result_value = nil, raise_error: false) expect(result.unhandled_error).to be_an_instance_of TestJob::ExpectedError end - if Gem::Version.new(Rails.version) > Gem::Version.new("6") - # Necessary instrumentation was added in Rails 6.0 - context 'when retry_on is used' do - before do - TestJob.retry_on(StandardError, wait: 0, attempts: Float::INFINITY) { nil } - end - - it 'returns the error' do - result = good_job.perform - - expect(result.value).to be_nil - expect(result.handled_error).to be_an_instance_of TestJob::ExpectedError - end + context 'when retry_on is used' do + before do + TestJob.retry_on(StandardError, wait: 0, attempts: Float::INFINITY) { nil } end - context 'when discard_on is used' do - before do - TestJob.discard_on(StandardError) { nil } - end + it 'returns the error' do + result = good_job.perform - it 'returns the error' do - result = good_job.perform + expect(result.value).to be_nil + expect(result.handled_error).to be_an_instance_of TestJob::ExpectedError + end + end + + context 'when discard_on is used' do + before do + TestJob.discard_on(StandardError) { nil } + end + + it 'returns the error' do + result = good_job.perform - expect(result.value).to be_nil - expect(result.handled_error).to be_an_instance_of TestJob::ExpectedError - end + expect(result.value).to be_nil + expect(result.handled_error).to be_an_instance_of TestJob::ExpectedError end end end