From 1a87630d54a2adc8053284f962db4070b1f0cc18 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 15:19:52 -0400 Subject: [PATCH 1/2] Add Rails 8.1 to the CI testing matrix --- .github/workflows/upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 5e2440a..8d56199 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: plat: ["ubuntu"] - ref: ["7-2-stable", "8-0-stable", "main"] + ref: ["7-2-stable", "8-0-stable", "8-1-stable", "main"] env: RAILSOPTS: --git=https://github.com/rails/rails --ref=${{ matrix.ref }} steps: From 770b8e90668f7a3b14aebeae8fb38188bd050d15 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Oct 2025 15:40:50 -0400 Subject: [PATCH 2/2] Gracefully handle the new Rails default of "no system tests" Fixes #585 --- CHANGELOG.md | 7 +++++++ lib/generators/test_unit/scaffold/scaffold_generator.rb | 7 +++---- test/integration/user_install_test.sh | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aae4aa4..917d8b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `tailwindcss-rails` Changelog +## next / unreleased + +### Improved + +* Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones + + ## v4.3.0 / 2025-07-06 ### Improved diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index c9f1647..511ca7d 100644 --- a/lib/generators/test_unit/scaffold/scaffold_generator.rb +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -4,10 +4,9 @@ module TestUnit # :nodoc: module Generators # :nodoc: class ScaffoldGenerator < Base # :nodoc: def fix_system_test - if turbo_defined? && options[:system_tests] - gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), - /(click_on.*Destroy this.*)$/, - "accept_confirm { \\1 }" + system_test_file = File.join("test/system", class_path, "#{file_name.pluralize}_test.rb") + if turbo_defined? && options[:system_tests] && File.exist?(system_test_file) + gsub_file(system_test_file, /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }") end end diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index c68123e..46b5056 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -69,8 +69,12 @@ if [[ $(rails -v) > "Rails 8.0.0.beta" ]] ; then grep -q PasswordsController app/controllers/passwords_controller.rb fi +# TEST: doesn't fail when not generating system tests +bin/rails generate scaffold memo title:string body:text published:boolean --system-tests=false +grep -q "Show" app/views/memos/index.html.erb + # TEST: presence of the generated file -bin/rails generate scaffold post title:string body:text published:boolean +bin/rails generate scaffold post title:string body:text published:boolean --system-tests=true grep -q "Show" app/views/posts/index.html.erb # TEST: the "accept_confirm" system test change was applied cleanly