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: 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