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 0a7cef8f5..044b92fb4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,8 +12,8 @@ PATH remote: . specs: good_job (2.17.1) - 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) @@ -73,11 +73,6 @@ GEM activerecord-explain-analyze (0.1.0) activerecord (>= 4) pg - activerecord-jdbc-adapter (61.2-java) - activerecord (~> 6.1.0) - activerecord-jdbcpostgresql-adapter (61.2-java) - activerecord-jdbc-adapter (= 61.2) - jdbc-postgres (>= 9.4, < 43) activestorage (6.1.5.1) actionpack (= 6.1.5.1) activejob (= 6.1.5.1) @@ -187,7 +182,6 @@ GEM faraday-rack (1.0.0) faraday-retry (1.0.3) ffi (1.15.5) - ffi (1.15.5-java) fiber-local (1.0.0) foreman (0.87.2) fugit (1.5.3) @@ -220,7 +214,6 @@ GEM rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) - jdbc-postgres (42.2.25) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) @@ -252,12 +245,9 @@ GEM multi_json (1.15.0) multipart-post (2.1.1) nio4r (2.5.8) - nio4r (2.5.8-java) nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) - nokogiri (1.12.5-java) - racc (~> 1.4) octokit (4.22.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) @@ -276,10 +266,6 @@ GEM pry (0.13.1) coderay (~> 1.1) method_source (~> 1.0) - pry (0.13.1-java) - coderay (~> 1.1) - method_source (~> 1.0) - spoon (~> 0.0) pry-byebug (3.9.0) byebug (~> 11.0) pry (~> 0.13.0) @@ -288,11 +274,8 @@ GEM public_suffix (4.0.7) puma (5.6.4) nio4r (~> 2.0) - puma (5.6.4-java) - nio4r (~> 2.0) raabro (1.4.0) racc (1.6.0) - racc (1.6.0-java) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) @@ -381,8 +364,6 @@ GEM rubyzip (>= 1.2.2) sigdump (0.2.4) smart_properties (1.17.0) - spoon (0.0.6) - ffi sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -403,8 +384,6 @@ GEM webrick (1.7.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-driver (0.7.5-java) - websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) 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 74975b516..51eaba704 100644 --- a/good_job.gemspec +++ b/good_job.gemspec @@ -50,8 +50,8 @@ 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" 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/good_job/execution_spec.rb b/spec/lib/good_job/execution_spec.rb index 622643d55..14f91e07f 100644 --- a/spec/lib/good_job/execution_spec.rb +++ b/spec/lib/good_job/execution_spec.rb @@ -287,32 +287,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