From 5411955b91d0a9ea1d317c377e09a1c2f1687dd2 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Tue, 16 Jan 2024 17:14:39 +0100 Subject: [PATCH 1/4] chore: Update gemfiles and CI settings for newer Rails versions This commit removes support for Rails 5.2 and updates gemfiles for Rails 6.0, 6.1, and 7.0. It also adds support for Rails 7.1. The CI settings are updated to reflect these changes, now testing on newer Ruby versions and using updated versions of Github Actions. --- .github/workflows/ci.yml | 9 ++--- .gitignore | 3 ++ Appraisals | 37 +++++++++++-------- gemfiles/rails_6.0.gemfile | 7 ++-- gemfiles/rails_6.1.gemfile | 7 ++-- gemfiles/rails_7.0.gemfile | 13 ++----- .../{rails_5.2.gemfile => rails_7.1.gemfile} | 11 +++--- gems.rb | 12 ++++++ test/dummy/config/database.yml | 8 +--- test/integration/artists_controller_test.rb | 1 + test/integration/cells_controller_test.rb | 1 + test/integration/songs_controller_test.rb | 1 + test/song/operation_test.rb | 2 +- test/test_helper.rb | 1 + trailblazer-rails.gemspec | 6 +-- 15 files changed, 62 insertions(+), 57 deletions(-) rename gemfiles/{rails_5.2.gemfile => rails_7.1.gemfile} (67%) create mode 100644 gems.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5bd605..7d24340 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,20 +11,17 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.7, '3.0'] + ruby: ['3.0', '3.1', '3.2', '3.3'] gemfile: + - rails_7.1 - rails_7.0 - rails_6.1 - rails_6.0 - - rails_5.2 - exclude: - - ruby: '3.0' - gemfile: rails_5.2 runs-on: ubuntu-latest env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/.gitignore b/.gitignore index 2903abf..d927810 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ test/**/Gemfile.lock *.iml *.sqlite3 .tool-versions +gems.locked +gemfiles/*.lock + diff --git a/Appraisals b/Appraisals index 1608e44..7bac302 100644 --- a/Appraisals +++ b/Appraisals @@ -1,19 +1,24 @@ -appraise "rails-6.0" do - gem "actionpack", "~> 6.0.0" - gem "activerecord", "~> 6.0.0" -end -appraise "rails-6.1" do - gem "actionpack", "~> 6.1.0" - gem "activerecord", "~> 6.1.0" +# frozen_string_literal: true + +appraise 'rails-6.0' do + gem 'actionpack', '~> 6.0.0' + gem 'activerecord', '~> 6.0.0' + gem 'sqlite3', '~> 1.4.0' end -appraise "rails-7.0" do - gem "actionpack", "~> 7.0.0" - gem "activerecord", "~> 7.0.0" - gem "sqlite3", "~> 1.4.0" + +appraise 'rails-6.1' do + gem 'actionpack', '~> 6.1.0' + gem 'activerecord', '~> 6.1.0' + gem 'sqlite3', '~> 1.4.0' end -appraise "rails-5.2" do - gem "actionpack", "~> 5.2.0" - gem "activerecord", "~> 5.2.0" - gem "sqlite3", "~> 1.3.8" -end \ No newline at end of file +appraise 'rails-7.0' do + gem 'actionpack', '~> 7.0.0' + gem 'activerecord', '~> 7.0.0' + gem 'sqlite3', '~> 1.4.0' +end +appraise 'rails-7.1' do + gem 'actionpack', '~> 7.0.0' + gem 'activerecord', '~> 7.0.0' + gem 'sqlite3', '~> 1.4.0' +end diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index 1cb0f81..01a3a8c 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -2,16 +2,15 @@ source "https://rubygems.org" +gem "appraisal" +gem "minitest-capybara" gem "cells-erb" gem "cells-rails" gem "reform-rails" gem "trailblazer" gem "trailblazer-cells" -gem "trailblazer-loader" -gem "sqlite3" -gem "minitest-capybara" -gem "appraisal" gem "actionpack", "~> 6.0.0" gem "activerecord", "~> 6.0.0" +gem "sqlite3", "~> 1.4.0" gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index 2cc837f..08aa33e 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -2,16 +2,15 @@ source "https://rubygems.org" +gem "appraisal" +gem "minitest-capybara" gem "cells-erb" gem "cells-rails" gem "reform-rails" gem "trailblazer" gem "trailblazer-cells" -gem "trailblazer-loader" -gem "sqlite3" -gem "minitest-capybara" -gem "appraisal" gem "actionpack", "~> 6.1.0" gem "activerecord", "~> 6.1.0" +gem "sqlite3", "~> 1.4.0" gemspec path: "../" diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index e774ea3..fbe91c9 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -2,22 +2,15 @@ source "https://rubygems.org" +gem "appraisal" +gem "minitest-capybara" gem "cells-erb" gem "cells-rails" gem "reform-rails" gem "trailblazer" gem "trailblazer-cells" -gem "sqlite3", "~> 1.4.0" -gem "minitest-capybara" -gem "appraisal" gem "actionpack", "~> 7.0.0" gem "activerecord", "~> 7.0.0" - -# gem "trailblazer-macro", path: "../../trailblazer-macro" -# gem "trailblazer-macro-contract", path: "../../trailblazer-macro-contract" -# gem "trailblazer-activity", path: "../../trailblazer-activity" -# gem "trailblazer-operation", path: "../../trailblazer-operation" -# gem "trailblazer-developer", path: "../../trailblazer-developer" -# gem "trailblazer-activity-dsl-linear", path: "../../trailblazer-activity-dsl-linear" +gem "sqlite3", "~> 1.4.0" gemspec path: "../" diff --git a/gemfiles/rails_5.2.gemfile b/gemfiles/rails_7.1.gemfile similarity index 67% rename from gemfiles/rails_5.2.gemfile rename to gemfiles/rails_7.1.gemfile index 73ef0ce..fbe91c9 100644 --- a/gemfiles/rails_5.2.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -2,16 +2,15 @@ source "https://rubygems.org" +gem "appraisal" +gem "minitest-capybara" gem "cells-erb" gem "cells-rails" gem "reform-rails" gem "trailblazer" gem "trailblazer-cells" -gem "trailblazer-loader" -gem "sqlite3", "~> 1.3.8" -gem "minitest-capybara" -gem "appraisal" -gem "actionpack", "~> 5.2.0" -gem "activerecord", "~> 5.2.0" +gem "actionpack", "~> 7.0.0" +gem "activerecord", "~> 7.0.0" +gem "sqlite3", "~> 1.4.0" gemspec path: "../" diff --git a/gems.rb b/gems.rb new file mode 100644 index 0000000..87345ec --- /dev/null +++ b/gems.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' +gemspec + +gem 'appraisal' +gem 'minitest-capybara' +gem "cells-erb" +gem "cells-rails" +gem "reform-rails" +gem "trailblazer" +gem "trailblazer-cells" \ No newline at end of file diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index 92b6398..1ca5fe1 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -1,11 +1,5 @@ -default: &default +test: adapter: sqlite3 pool: 5 timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default database: db/test.sqlite3 diff --git a/test/integration/artists_controller_test.rb b/test/integration/artists_controller_test.rb index 9e77a81..baa929a 100644 --- a/test/integration/artists_controller_test.rb +++ b/test/integration/artists_controller_test.rb @@ -1,4 +1,5 @@ require "test_helper" +require 'minitest/capybara' class ArtistsControllerTest < Minitest::Capybara::Spec it "cell: Artist::Cell::Dashboard" do diff --git a/test/integration/cells_controller_test.rb b/test/integration/cells_controller_test.rb index ddcc3b1..9a3e522 100644 --- a/test/integration/cells_controller_test.rb +++ b/test/integration/cells_controller_test.rb @@ -1,4 +1,5 @@ require "test_helper" +require 'minitest/capybara' class CellsControllerTest < Minitest::Capybara::Spec it "" do diff --git a/test/integration/songs_controller_test.rb b/test/integration/songs_controller_test.rb index b722aad..72b8c0c 100644 --- a/test/integration/songs_controller_test.rb +++ b/test/integration/songs_controller_test.rb @@ -1,4 +1,5 @@ require "test_helper" +require 'minitest/capybara' class SongsControllerTest < Minitest::Capybara::Spec it "new" do diff --git a/test/song/operation_test.rb b/test/song/operation_test.rb index 0f493d3..d661382 100644 --- a/test/song/operation_test.rb +++ b/test/song/operation_test.rb @@ -1,7 +1,7 @@ require "test_helper" require "trailblazer/activity/testing" -class SongOperationTest < Minitest::Spec +class SongOperationTest < Minitest::TrailblazerSpec it "what" do song = Song.create(title: "Bright Eyes") diff --git a/test/test_helper.rb b/test/test_helper.rb index 6938605..4670848 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,3 +3,4 @@ require "minitest/autorun" require "capybara/rails" +require 'minitest/trailblazer_spec' diff --git a/trailblazer-rails.gemspec b/trailblazer-rails.gemspec index 980156c..1743996 100644 --- a/trailblazer-rails.gemspec +++ b/trailblazer-rails.gemspec @@ -1,6 +1,4 @@ -lib = File.expand_path("lib", __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "trailblazer/rails/version" +require_relative "lib/trailblazer/rails/version" Gem::Specification.new do |spec| spec.name = "trailblazer-rails" @@ -21,4 +19,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler" spec.add_development_dependency "minitest" spec.add_development_dependency "rake" + spec.add_development_dependency "capybara" + spec.add_development_dependency "minitest-trailblazer" end From b9ab5e4535566f7876cca15056dcc9401afbdc9f Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 13 Jun 2024 15:31:13 +0100 Subject: [PATCH 2/4] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d24340..970f03a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['3.0', '3.1', '3.2', '3.3'] + ruby: ['2.7', '3.0', '3.1', '3.2', '3.3'] gemfile: - rails_7.1 - rails_7.0 @@ -26,4 +26,4 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - run: bundle exec rake db:create db:schema:load test \ No newline at end of file + - run: bundle exec rake db:create db:schema:load test From 7c9643c7aa08a16cac4b007cceaba1439c4b1b9e Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 13 Jun 2024 15:54:43 +0100 Subject: [PATCH 3/4] fix up --- Appraisals | 4 ++-- Rakefile | 7 ++----- gemfiles/rails_7.1.gemfile | 4 ++-- test/dummy/config/application.rb | 1 - test/song/operation_test.rb | 2 +- test/test_helper.rb | 1 - trailblazer-rails.gemspec | 3 +-- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Appraisals b/Appraisals index 7bac302..a5dd337 100644 --- a/Appraisals +++ b/Appraisals @@ -18,7 +18,7 @@ appraise 'rails-7.0' do gem 'sqlite3', '~> 1.4.0' end appraise 'rails-7.1' do - gem 'actionpack', '~> 7.0.0' - gem 'activerecord', '~> 7.0.0' + gem 'actionpack', '~> 7.1.0' + gem 'activerecord', '~> 7.q.0' gem 'sqlite3', '~> 1.4.0' end diff --git a/Rakefile b/Rakefile index 07e03de..f9604e0 100644 --- a/Rakefile +++ b/Rakefile @@ -8,11 +8,8 @@ Rake::TestTask.new(:test) do |t| t.test_files = FileList["test/**/*_test.rb"] end -begin - require File.expand_path("test/dummy/config/application", __dir__) - Rails.application.load_tasks -rescue LoadError -end +require File.expand_path("test/dummy/config/application", __dir__) +Rails.application.load_tasks desc "Running Tests" task default: :test diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index fbe91c9..303131d 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -9,8 +9,8 @@ gem "cells-rails" gem "reform-rails" gem "trailblazer" gem "trailblazer-cells" -gem "actionpack", "~> 7.0.0" -gem "activerecord", "~> 7.0.0" +gem "actionpack", "~> 7.1.0" +gem "activerecord", "~> 7.q.0" gem "sqlite3", "~> 1.4.0" gemspec path: "../" diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 086004e..f574066 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -11,7 +11,6 @@ module TrailblazerTestApp class Application < Rails::Application config.load_defaults Rails.gem_version.to_s.split(".")[0..1].join(".") - config.active_record.legacy_connection_handling = false if Rails.gem_version >= Gem::Version.new("6.1") config.cache_classes = true config.eager_load = false config.serve_static_files = false diff --git a/test/song/operation_test.rb b/test/song/operation_test.rb index d661382..0f493d3 100644 --- a/test/song/operation_test.rb +++ b/test/song/operation_test.rb @@ -1,7 +1,7 @@ require "test_helper" require "trailblazer/activity/testing" -class SongOperationTest < Minitest::TrailblazerSpec +class SongOperationTest < Minitest::Spec it "what" do song = Song.create(title: "Bright Eyes") diff --git a/test/test_helper.rb b/test/test_helper.rb index 4670848..6938605 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,4 +3,3 @@ require "minitest/autorun" require "capybara/rails" -require 'minitest/trailblazer_spec' diff --git a/trailblazer-rails.gemspec b/trailblazer-rails.gemspec index 1743996..dedb783 100644 --- a/trailblazer-rails.gemspec +++ b/trailblazer-rails.gemspec @@ -13,12 +13,11 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) } spec.require_paths = ["lib"] - spec.add_dependency "railties", ">= 5.2.0" + spec.add_dependency "railties", ">= 6.0.0" spec.add_dependency "trailblazer", ">= 2.1.0", "< 2.2.0" spec.add_development_dependency "bundler" spec.add_development_dependency "minitest" spec.add_development_dependency "rake" spec.add_development_dependency "capybara" - spec.add_development_dependency "minitest-trailblazer" end From e778778dcb8e467ecd47c3389a51453dd8950de9 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 13 Jun 2024 16:09:50 +0100 Subject: [PATCH 4/4] fix output --- test/dummy/app/models/song.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/dummy/app/models/song.rb b/test/dummy/app/models/song.rb index 7c9dbf0..bd4aa53 100644 --- a/test/dummy/app/models/song.rb +++ b/test/dummy/app/models/song.rb @@ -1,2 +1,9 @@ class Song < ApplicationRecord + + def inspect + # this makes the output consistent across Ruby versions + title = self.title.present? ? "\"#{self.title}\"" : "nil" + id = self.id.present? ? self.id : "nil" + %{#} + end end