From 597d548aa3fd05985d24c3b57b2d0c5f91196002 Mon Sep 17 00:00:00 2001 From: Henk <henk.van.der.veen@gmail.com> Date: Tue, 30 Mar 2021 23:59:47 +0200 Subject: [PATCH] Support rails 6.1, drop support or rails 5.1 --- .gitlab-ci.yml | 28 +++++++++++++++---- Appraisals | 13 ++++----- Gemfile | 4 +-- Gemfile.lock | 8 ++++-- gemfiles/rails52.gemfile | 4 +-- gemfiles/rails60.gemfile | 3 +- gemfiles/{rails51.gemfile => rails61.gemfile} | 6 ++-- lib/roqua/scheduling/scheduler.rb | 5 +++- lib/roqua/validators/subset_validator.rb | 2 +- roqua-support.gemspec | 2 +- spec/roqua/scheduling/scheduler_spec.rb | 2 +- 11 files changed, 48 insertions(+), 29 deletions(-) rename gemfiles/{rails51.gemfile => rails61.gemfile} (82%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9af023..46c9b22 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,8 +5,7 @@ before_script: - if [ -x "$(command -v apk)" ]; then apk add sqlite-dev; fi - export BUNDLE_PATH=$CI_PROJECT_DIR/.gems - bundle --jobs 2 --retry 3 - - bundle exec appraisal - - bundle --jobs 2 --retry 3 + - bundle exec appraisal install .ruby_25: &ruby_25 image: registry.roqua.nl/roqua/docker-base-images:ruby-2.5 @@ -22,10 +21,12 @@ before_script: paths: - .gems -rails_51_ruby_25: - <<: *ruby_25 - script: - - bundle exec appraisal rails51 bundle exec rspec +.ruby_27: &ruby_27 + image: registry.roqua.nl/roqua/docker-base-images:ruby-2.7-builder + cache: + key: ruby_27 + paths: + - .gems rails_52_ruby_25: <<: *ruby_25 @@ -37,6 +38,11 @@ rails_52_ruby_26: script: - bundle exec appraisal rails52 bundle exec rspec +rails_52_ruby_27: + <<: *ruby_27 + script: + - bundle exec appraisal rails52 bundle exec rspec + rails_60_ruby_25: <<: *ruby_25 script: @@ -46,3 +52,13 @@ rails_60_ruby_26: <<: *ruby_26 script: - bundle exec appraisal rails60 bundle exec rspec + +rails_60_ruby_27: + <<: *ruby_27 + script: + - bundle exec appraisal rails60 bundle exec rspec + +rails_61_ruby_27: + <<: *ruby_27 + script: + - bundle exec appraisal rails61 bundle exec rspec diff --git a/Appraisals b/Appraisals index 1438b61..e1e5cf8 100644 --- a/Appraisals +++ b/Appraisals @@ -1,16 +1,15 @@ -appraise "rails51" do - gem "activesupport", "~> 5.1.0" - gem 'sqlite3', '~> 1.3.6' -end - appraise "rails52" do + gem "active_interaction", "~> 3.0" gem "activesupport", "~> 5.2.0" - gem 'sqlite3', '~> 1.4' gem 'appsignal', '~> 2.9.8' # test each minor versions we support end appraise "rails60" do gem "activesupport", "~> 6.0.0" - gem 'sqlite3', '~> 1.4' gem 'appsignal', '~> 2.10.6' end + +appraise "rails61" do + gem "activesupport", "~> 6.1.0" + gem 'appsignal', '~> 3.0.0' +end diff --git a/Gemfile b/Gemfile index 4dfd599..15a7c3c 100644 --- a/Gemfile +++ b/Gemfile @@ -7,8 +7,8 @@ gem 'appraisal' gem 'roqua_styleguide', git: 'https://gitlab.roqua.nl/roqua/styleguide.git' group :test do + gem 'sqlite3' gem 'actionpack', '>= 4.0' - gem 'active_interaction', '~> 3.0' gem 'climate_control' # For ENV modification in specs gem 'combustion', '~> 1.1.1' gem 'fakefs', require: 'fakefs/safe' @@ -17,4 +17,4 @@ group :test do gem 'rspec-instrumentation-matcher' gem 'rspec-rails' gem 'pry' -end \ No newline at end of file +end diff --git a/Gemfile.lock b/Gemfile.lock index c8fe020..b8f1548 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,9 +10,9 @@ PATH remote: . specs: roqua-support (0.3.5) - active_interaction (~> 3.0) - activesupport (>= 5.1, < 6.1) - appsignal (>= 2.9, < 2.11) + active_interaction (>= 3.0, < 5.0) + activesupport (>= 5.2, < 6.2) + appsignal (>= 2.9, < 3.1) naught (~> 1.0) with_advisory_lock (~> 3.2) @@ -170,6 +170,7 @@ GEM rubocop (>= 0.72.0) ruby-progressbar (1.10.1) shellany (0.0.1) + sqlite3 (1.4.2) thor (1.0.1) thread_safe (0.3.6) timecop (0.9.1) @@ -201,6 +202,7 @@ DEPENDENCIES rspec (>= 2.12.0, < 4.0) rspec-instrumentation-matcher rspec-rails + sqlite3 timecop BUNDLED WITH diff --git a/gemfiles/rails52.gemfile b/gemfiles/rails52.gemfile index 7299095..4a3abdc 100644 --- a/gemfiles/rails52.gemfile +++ b/gemfiles/rails52.gemfile @@ -4,13 +4,13 @@ source "https://rubygems.org" gem "appraisal" gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git" +gem "active_interaction", "~> 3.0" gem "activesupport", "~> 5.2.0" -gem "sqlite3", "~> 1.4" gem "appsignal", "~> 2.9.8" group :test do + gem "sqlite3" gem "actionpack", ">= 4.0" - gem "active_interaction", "~> 3.0" gem "climate_control" gem "combustion", "~> 1.1.1" gem "fakefs", require: "fakefs/safe" diff --git a/gemfiles/rails60.gemfile b/gemfiles/rails60.gemfile index 441fc36..0d4f4d5 100644 --- a/gemfiles/rails60.gemfile +++ b/gemfiles/rails60.gemfile @@ -5,12 +5,11 @@ source "https://rubygems.org" gem "appraisal" gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git" gem "activesupport", "~> 6.0.0" -gem "sqlite3", "~> 1.4" gem "appsignal", "~> 2.10.6" group :test do + gem "sqlite3" gem "actionpack", ">= 4.0" - gem "active_interaction", "~> 3.0" gem "climate_control" gem "combustion", "~> 1.1.1" gem "fakefs", require: "fakefs/safe" diff --git a/gemfiles/rails51.gemfile b/gemfiles/rails61.gemfile similarity index 82% rename from gemfiles/rails51.gemfile rename to gemfiles/rails61.gemfile index 8d854c2..64efbef 100644 --- a/gemfiles/rails51.gemfile +++ b/gemfiles/rails61.gemfile @@ -4,12 +4,12 @@ source "https://rubygems.org" gem "appraisal" gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git" -gem "activesupport", "~> 5.1.0" -gem "sqlite3", "~> 1.3.6" +gem "activesupport", "~> 6.1.0" +gem "appsignal", "~> 3.0.0" group :test do + gem "sqlite3" gem "actionpack", ">= 4.0" - gem "active_interaction", "~> 3.0" gem "climate_control" gem "combustion", "~> 1.1.1" gem "fakefs", require: "fakefs/safe" diff --git a/lib/roqua/scheduling/scheduler.rb b/lib/roqua/scheduling/scheduler.rb index fc2e8be..c212dfc 100644 --- a/lib/roqua/scheduling/scheduler.rb +++ b/lib/roqua/scheduling/scheduler.rb @@ -29,7 +29,10 @@ class Roqua::Scheduling::Scheduler end def advisory_lock_name - "#{ActiveRecord::Base.connection_config[:database]}_cron_lock" + db_name = ActiveRecord::Base.respond_to?(:connection_db_config) \ + ? ActiveRecord::Base.connection_db_config.database + : ActiveRecord::Base.connection_config[:database] + "#{db_name}_cron_lock" end private diff --git a/lib/roqua/validators/subset_validator.rb b/lib/roqua/validators/subset_validator.rb index 27b3fb6..975474a 100644 --- a/lib/roqua/validators/subset_validator.rb +++ b/lib/roqua/validators/subset_validator.rb @@ -6,7 +6,7 @@ class SubsetValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return unless value unless value.all? { |element| options.fetch(:of).include? element } - record.errors[attribute] << (options[:message] || I18n.t('errors.messages.subset')) + record.errors.add attribute, (options[:message] || I18n.t('errors.messages.subset')) end end end diff --git a/roqua-support.gemspec b/roqua-support.gemspec index 826438d..91c27f1 100644 --- a/roqua-support.gemspec +++ b/roqua-support.gemspec @@ -19,8 +19,8 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.required_ruby_version = '>= 2.5' - gem.add_dependency 'activesupport', '>= 5.1', '< 6.1' gem.add_dependency 'active_interaction', '>= 3.0', '< 5.0' + gem.add_dependency 'activesupport', '>= 5.2', '< 6.2' gem.add_dependency 'naught', '~> 1.0' gem.add_dependency 'with_advisory_lock', '~> 3.2' gem.add_dependency 'appsignal', '>= 2.9', '< 3.1' diff --git a/spec/roqua/scheduling/scheduler_spec.rb b/spec/roqua/scheduling/scheduler_spec.rb index 276984c..d6e7760 100644 --- a/spec/roqua/scheduling/scheduler_spec.rb +++ b/spec/roqua/scheduling/scheduler_spec.rb @@ -51,7 +51,7 @@ describe Roqua::Scheduling::Scheduler do end it 'generates a database specific advisory lock name' do - expect(ActiveRecord::Base.connection_config[:database]).to eql(':memory:') + # expect(ActiveRecord::Base.connection_config[:database]).to eql(':memory:') expect(subject.advisory_lock_name).to eql ':memory:_cron_lock' end -- GitLab