From 0c7b467a2ec655b6ca22dbeb6c6d860c0ea8a992 Mon Sep 17 00:00:00 2001 From: Alfonso Uceda Date: Mon, 11 Nov 2024 12:01:14 +0100 Subject: [PATCH 1/3] Rails8 is supported --- .github/workflows/ci.yml | 33 ++++++++++++++----- Appraisals | 5 ++- Gemfile | 2 +- cells-rails.gemspec | 1 + gemfiles/5.2.gemfile | 2 +- gemfiles/6.0.gemfile | 2 +- gemfiles/6.1.gemfile | 2 +- gemfiles/7.0.gemfile | 2 +- gemfiles/8.0.gemfile | 15 +++++++++ lib/cell/rails/testing.rb | 4 +-- test/dummy/Gemfile | 4 +-- test/dummy/config/boot.rb | 1 + test/dummy/test/caching_test.rb | 4 +-- test/dummy/test/context_test.rb | 2 +- test/dummy/test/integration/form_for_test.rb | 2 +- test/dummy/test/integration/form_tag_test.rb | 2 +- .../dummy/test/integration/formtastic_test.rb | 2 +- .../test/integration/simple_form_test.rb | 2 +- .../dummy/test/integration/url_helper_test.rb | 4 +-- test/dummy/test/public_test.rb | 2 +- test/dummy/test/rails_extensions_test.rb | 1 + test/dummy/test/test_helper.rb | 2 +- test/dummy/test/translation_test.rb | 2 +- test/test_helper.rb | 1 + 24 files changed, 69 insertions(+), 30 deletions(-) create mode 100644 gemfiles/8.0.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91b0b8b..5d19c96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,39 +6,56 @@ jobs: fail-fast: false matrix: # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head] + ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, head] gemfile: + - gemfiles/8.0.gemfile - gemfiles/7.0.gemfile - gemfiles/6.0.gemfile - gemfiles/5.2.gemfile exclude: - ruby: 2.5 gemfile: gemfiles/7.0.gemfile + - ruby: 2.5 + gemfile: gemfiles/8.0.gemfile + - ruby: 2.6 + gemfile: gemfiles/7.0.gemfile - ruby: 2.6 + gemfile: gemfiles/8.0.gemfile + - ruby: 2.7 gemfile: gemfiles/7.0.gemfile + - ruby: 2.7 + gemfile: gemfiles/8.0.gemfile - ruby: 3.0 gemfile: gemfiles/5.2.gemfile + - ruby: 3.0 + gemfile: gemfiles/8.0.gemfile - ruby: 3.1 gemfile: gemfiles/5.2.gemfile - ruby: 3.1 gemfile: gemfiles/6.0.gemfile + - ruby: 3.1 + gemfile: gemfiles/8.0.gemfile - ruby: 3.2 gemfile: gemfiles/5.2.gemfile - ruby: 3.2 gemfile: gemfiles/6.0.gemfile + - ruby: 3.3 + gemfile: gemfiles/5.2.gemfile + - ruby: 3.3 + gemfile: gemfiles/6.0.gemfile - ruby: head gemfile: gemfiles/5.2.gemfile - ruby: head gemfile: gemfiles/6.0.gemfile - + runs-on: ubuntu-latest env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: - - uses: actions/checkout@v2 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - run: bundle exec rake + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - run: bundle exec rake diff --git a/Appraisals b/Appraisals index 251745b..4928c26 100644 --- a/Appraisals +++ b/Appraisals @@ -1,3 +1,7 @@ +appraise "8.0" do + gem "railties", "~> 8.0.0" +end + appraise "7.0" do gem "railties", "~> 7.0.0" end @@ -13,4 +17,3 @@ end appraise "5.2" do gem "railties", "~> 5.2.0" end - diff --git a/Gemfile b/Gemfile index 098aee3..cdc6d03 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem "my_engine", path: "test/dummy/engines/my_engine" group :development, :test do gem "minitest-spec-rails" - gem "capybara_minitest_spec" + gem "capybara" end gem "simple_form" diff --git a/cells-rails.gemspec b/cells-rails.gemspec index bbe834b..ae7a598 100644 --- a/cells-rails.gemspec +++ b/cells-rails.gemspec @@ -33,4 +33,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails' spec.add_development_dependency 'rake' spec.add_development_dependency 'sass-rails' + spec.add_development_dependency 'debug' end diff --git a/gemfiles/5.2.gemfile b/gemfiles/5.2.gemfile index 7c1e01b..a78e88f 100644 --- a/gemfiles/5.2.gemfile +++ b/gemfiles/5.2.gemfile @@ -9,7 +9,7 @@ gem "railties", "~> 5.2.0" group :development, :test do gem "minitest-spec-rails" - gem "capybara_minitest_spec" + gem "capybara" end gemspec path: "../" diff --git a/gemfiles/6.0.gemfile b/gemfiles/6.0.gemfile index 9889cf7..7abfc7d 100644 --- a/gemfiles/6.0.gemfile +++ b/gemfiles/6.0.gemfile @@ -9,7 +9,7 @@ gem "railties", "~> 6.0" group :development, :test do gem "minitest-spec-rails" - gem "capybara_minitest_spec" + gem "capybara" end gemspec path: "../" diff --git a/gemfiles/6.1.gemfile b/gemfiles/6.1.gemfile index 15d19b0..a63b58a 100644 --- a/gemfiles/6.1.gemfile +++ b/gemfiles/6.1.gemfile @@ -9,7 +9,7 @@ gem "railties", "~> 6.1.0" group :development, :test do gem "minitest-spec-rails" - gem "capybara_minitest_spec" + gem "capybara" end gemspec path: "../" diff --git a/gemfiles/7.0.gemfile b/gemfiles/7.0.gemfile index f3844d4..4a733cf 100644 --- a/gemfiles/7.0.gemfile +++ b/gemfiles/7.0.gemfile @@ -9,7 +9,7 @@ gem "railties", "~> 7.0.0" group :development, :test do gem "minitest-spec-rails" - gem "capybara_minitest_spec" + gem "capybara" end gemspec path: "../" diff --git a/gemfiles/8.0.gemfile b/gemfiles/8.0.gemfile new file mode 100644 index 0000000..42b0c18 --- /dev/null +++ b/gemfiles/8.0.gemfile @@ -0,0 +1,15 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "my_engine", path: "../test/dummy/engines/my_engine" +gem "simple_form" +gem "formtastic" +gem "railties", "~> 8.0.0" + +group :development, :test do + gem "minitest-spec-rails" + gem "capybara" +end + +gemspec path: "../" diff --git a/lib/cell/rails/testing.rb b/lib/cell/rails/testing.rb index 2b65101..363b494 100644 --- a/lib/cell/rails/testing.rb +++ b/lib/cell/rails/testing.rb @@ -2,7 +2,7 @@ module Cell module RailsExtensions # This modules overrides Cell::Testing#controller_for and provides Rails-specific logic. module Testing - RAILS_8_0 = Gem::Version.new("8.0.0") + RAILS_9_0 = Gem::Version.new("9.0.0") RAILS_5_1 = Gem::Version.new("5.1.0") RAILS_5_0 = Gem::Version.new("5.0.0") @@ -18,7 +18,7 @@ def controller_for(controller_class) def action_controller_test_request(controller_class) version = ::Rails.gem_version - if version >= RAILS_5_1 && version < RAILS_8_0 + if version >= RAILS_5_1 && version < RAILS_9_0 ::ActionController::TestRequest.create(controller_class) elsif version >= RAILS_5_0 && version < RAILS_5_1 ::ActionController::TestRequest.create diff --git a/test/dummy/Gemfile b/test/dummy/Gemfile index ef0c50a..2e9ceb7 100644 --- a/test/dummy/Gemfile +++ b/test/dummy/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '~> 7.0.0' +gem 'rails', '~> 8.0.0' gem "my_engine", path: "engines/my_engine" @@ -9,7 +9,7 @@ gem "sprockets" group :development, :test do gem "minitest-spec-rails" - gem "capybara_minitest_spec" + gem "capybara" end gem "cells", ">= 4.1.6" diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 6b750f0..e1d41dd 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,3 +1,4 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'ostruct' diff --git a/test/dummy/test/caching_test.rb b/test/dummy/test/caching_test.rb index c679998..1c924b4 100644 --- a/test/dummy/test/caching_test.rb +++ b/test/dummy/test/caching_test.rb @@ -17,7 +17,7 @@ def tock end -class CachingUnitTest < MiniTest::Spec +class CachingUnitTest < Minitest::Spec before :each do ActionController::Base.cache_store.clear ActionController::Base.perform_caching = true @@ -115,7 +115,7 @@ class CachingUnitTest < MiniTest::Spec end -class CachingTest < MiniTest::Spec +class CachingTest < Minitest::Spec class DirectorCell < Cell::ViewModel def initialize(counter=0) super diff --git a/test/dummy/test/context_test.rb b/test/dummy/test/context_test.rb index 745281d..3b49e2e 100644 --- a/test/dummy/test/context_test.rb +++ b/test/dummy/test/context_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class ContextTest < MiniTest::Spec +class ContextTest < Minitest::Spec class ParentCell < Cell::ViewModel def user context[:user] diff --git a/test/dummy/test/integration/form_for_test.rb b/test/dummy/test/integration/form_for_test.rb index 46d2531..09b7556 100644 --- a/test/dummy/test/integration/form_for_test.rb +++ b/test/dummy/test/integration/form_for_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class FormForTestTest < MiniTest::Spec +class FormForTestTest < Minitest::Spec include Cell::Testing it do diff --git a/test/dummy/test/integration/form_tag_test.rb b/test/dummy/test/integration/form_tag_test.rb index 5211420..f3ded2b 100644 --- a/test/dummy/test/integration/form_tag_test.rb +++ b/test/dummy/test/integration/form_tag_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class FormTagTestTest < MiniTest::Spec +class FormTagTestTest < Minitest::Spec include Cell::Testing controller SongsController diff --git a/test/dummy/test/integration/formtastic_test.rb b/test/dummy/test/integration/formtastic_test.rb index 366e227..5635a12 100644 --- a/test/dummy/test/integration/formtastic_test.rb +++ b/test/dummy/test/integration/formtastic_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class FormForTestTest < MiniTest::Spec +class FormForTestTest < Minitest::Spec include Cell::Testing controller SongsController # provides #url_options. diff --git a/test/dummy/test/integration/simple_form_test.rb b/test/dummy/test/integration/simple_form_test.rb index 478b885..2e89b8d 100644 --- a/test/dummy/test/integration/simple_form_test.rb +++ b/test/dummy/test/integration/simple_form_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class SimpleFormTest < MiniTest::Spec +class SimpleFormTest < Minitest::Spec include Cell::Testing controller SongsController # provides #url_options. diff --git a/test/dummy/test/integration/url_helper_test.rb b/test/dummy/test/integration/url_helper_test.rb index d53452f..30ac16e 100644 --- a/test/dummy/test/integration/url_helper_test.rb +++ b/test/dummy/test/integration/url_helper_test.rb @@ -16,7 +16,7 @@ def show end end -class UrlHelperTest < MiniTest::Spec +class UrlHelperTest < Minitest::Spec include Cell::Testing controller MusiciansController @@ -42,7 +42,7 @@ class UrlTest < ActionDispatch::IntegrationTest # end end -class DefaultOptionsTest < MiniTest::Spec +class DefaultOptionsTest < Minitest::Spec include Cell::Testing controller WithDefaultOptionsController diff --git a/test/dummy/test/public_test.rb b/test/dummy/test/public_test.rb index aaae3be..f7e2674 100644 --- a/test/dummy/test/public_test.rb +++ b/test/dummy/test/public_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class PublicTest < MiniTest::Spec +class PublicTest < Minitest::Spec # ::rails_version it { _(Cell.rails_version).must_equal Gem::Version.new(ActionPack::VERSION::STRING) } diff --git a/test/dummy/test/rails_extensions_test.rb b/test/dummy/test/rails_extensions_test.rb index 2f4f5c6..4feac73 100644 --- a/test/dummy/test/rails_extensions_test.rb +++ b/test/dummy/test/rails_extensions_test.rb @@ -51,6 +51,7 @@ def with_title(with_title: '') end test "cell(..) with #call keyword args" do + skip("cells 4.1.7 does not support this") get :view_with_cell_with_call_keyword_args assert_equal "

test

A Tale That Wasn't Right", @response.body end diff --git a/test/dummy/test/test_helper.rb b/test/dummy/test/test_helper.rb index c65dea1..7b5aec6 100644 --- a/test/dummy/test/test_helper.rb +++ b/test/dummy/test/test_helper.rb @@ -2,7 +2,7 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' -# MiniTest::Spec.class_eval do +# Minitest::Spec.class_eval do # after :each do # # DatabaseCleaner.clean # Thing.delete_all diff --git a/test/dummy/test/translation_test.rb b/test/dummy/test/translation_test.rb index 529f0e9..5e83b5e 100644 --- a/test/dummy/test/translation_test.rb +++ b/test/dummy/test/translation_test.rb @@ -1,7 +1,7 @@ require "test_helper" require "cell/translation" -class TranslationTest < MiniTest::Spec +class TranslationTest < Minitest::Spec class I18nCell < Cell::ViewModel include ActionView::Helpers::TranslationHelper include Cell::Translation diff --git a/test/test_helper.rb b/test/test_helper.rb index 8e6367f..1fe33c6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,6 +5,7 @@ require 'cells-rails' require "cells-erb" require 'rails' +require 'debug' require_relative "dummy/config/environment" From eb247cf168ec7470ed3556abf77dff0c5af0afe4 Mon Sep 17 00:00:00 2001 From: Alfonso Uceda Date: Wed, 13 Nov 2024 10:56:12 +0100 Subject: [PATCH 2/3] Gemfile rails 7.2 is added Gemfile rails 7.0 is replaced with 7.1 --- .github/workflows/ci.yml | 17 +++++++++++++---- Appraisals | 8 ++++++-- gemfiles/{7.0.gemfile => 7.1.gemfile} | 2 +- gemfiles/7.2.gemfile | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) rename gemfiles/{7.0.gemfile => 7.1.gemfile} (90%) create mode 100644 gemfiles/7.2.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d19c96..509337a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,26 +9,35 @@ jobs: ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, head] gemfile: - gemfiles/8.0.gemfile - - gemfiles/7.0.gemfile + - gemfiles/7.2.gemfile + - gemfiles/7.1.gemfile - gemfiles/6.0.gemfile - gemfiles/5.2.gemfile exclude: - ruby: 2.5 - gemfile: gemfiles/7.0.gemfile + gemfile: gemfiles/7.2.gemfile + - ruby: 2.5 + gemfile: gemfiles/7.1.gemfile - ruby: 2.5 gemfile: gemfiles/8.0.gemfile - ruby: 2.6 - gemfile: gemfiles/7.0.gemfile + gemfile: gemfiles/7.2.gemfile + - ruby: 2.6 + gemfile: gemfiles/7.1.gemfile - ruby: 2.6 gemfile: gemfiles/8.0.gemfile - ruby: 2.7 - gemfile: gemfiles/7.0.gemfile + gemfile: gemfiles/7.2.gemfile + - ruby: 2.7 + gemfile: gemfiles/7.1.gemfile - ruby: 2.7 gemfile: gemfiles/8.0.gemfile - ruby: 3.0 gemfile: gemfiles/5.2.gemfile - ruby: 3.0 gemfile: gemfiles/8.0.gemfile + - ruby: 3.0 + gemfile: gemfiles/7.2.gemfile - ruby: 3.1 gemfile: gemfiles/5.2.gemfile - ruby: 3.1 diff --git a/Appraisals b/Appraisals index 4928c26..da31c4d 100644 --- a/Appraisals +++ b/Appraisals @@ -2,8 +2,12 @@ appraise "8.0" do gem "railties", "~> 8.0.0" end -appraise "7.0" do - gem "railties", "~> 7.0.0" +appraise "7.2" do + gem "railties", "~> 7.2.0" +end + +appraise "7.1" do + gem "railties", "~> 7.1.0" end appraise "6.1" do diff --git a/gemfiles/7.0.gemfile b/gemfiles/7.1.gemfile similarity index 90% rename from gemfiles/7.0.gemfile rename to gemfiles/7.1.gemfile index 4a733cf..1e8b2d7 100644 --- a/gemfiles/7.0.gemfile +++ b/gemfiles/7.1.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "my_engine", path: "../test/dummy/engines/my_engine" gem "simple_form" gem "formtastic" -gem "railties", "~> 7.0.0" +gem "railties", "~> 7.1.0" group :development, :test do gem "minitest-spec-rails" diff --git a/gemfiles/7.2.gemfile b/gemfiles/7.2.gemfile new file mode 100644 index 0000000..a4a5ec8 --- /dev/null +++ b/gemfiles/7.2.gemfile @@ -0,0 +1,15 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "my_engine", path: "../test/dummy/engines/my_engine" +gem "simple_form" +gem "formtastic" +gem "railties", "~> 7.2.0" + +group :development, :test do + gem "minitest-spec-rails" + gem "capybara" +end + +gemspec path: "../" From c0dacb77445ad5ad4cf7fc25ad72377ffea750bf Mon Sep 17 00:00:00 2001 From: Alfonso Uceda Date: Wed, 13 Nov 2024 11:30:36 +0100 Subject: [PATCH 3/3] Keyword arguments tests are corrected according to cells functionality --- test/dummy/app/cells/song_cell.rb | 4 ++-- test/dummy/test/rails_extensions_test.rb | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/dummy/app/cells/song_cell.rb b/test/dummy/app/cells/song_cell.rb index 2eb38f4..986e43b 100644 --- a/test/dummy/app/cells/song_cell.rb +++ b/test/dummy/app/cells/song_cell.rb @@ -10,8 +10,8 @@ def with_escaped render end - def with_title(with_title: '') - "

#{with_title}

" + def with_title(options) + "

#{options[:with_title]}

" end # include ActionView::Helpers::AssetUrlHelper # include Sprockets::Rails::Helper diff --git a/test/dummy/test/rails_extensions_test.rb b/test/dummy/test/rails_extensions_test.rb index 4feac73..e7b52e1 100644 --- a/test/dummy/test/rails_extensions_test.rb +++ b/test/dummy/test/rails_extensions_test.rb @@ -18,8 +18,8 @@ def show "#{model}" end - def with_title(with_title: '') - "

#{with_title}

#{model}" + def with_title(options) + "

#{options[:with_title]}

#{model}" end end @@ -51,7 +51,6 @@ def with_title(with_title: '') end test "cell(..) with #call keyword args" do - skip("cells 4.1.7 does not support this") get :view_with_cell_with_call_keyword_args assert_equal "

test

A Tale That Wasn't Right", @response.body end