Skip to content

Commit 770b8e9

Browse files
committed
Gracefully handle the new Rails default of "no system tests"
Fixes #585
1 parent 1a87630 commit 770b8e9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# `tailwindcss-rails` Changelog
22

3+
## next / unreleased
4+
5+
### Improved
6+
7+
* Support Rails 8.1 scaffolding which disables system tests by default. #585 @flavorjones
8+
9+
310
## v4.3.0 / 2025-07-06
411

512
### Improved

lib/generators/test_unit/scaffold/scaffold_generator.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ module TestUnit # :nodoc:
44
module Generators # :nodoc:
55
class ScaffoldGenerator < Base # :nodoc:
66
def fix_system_test
7-
if turbo_defined? && options[:system_tests]
8-
gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"),
9-
/(click_on.*Destroy this.*)$/,
10-
"accept_confirm { \\1 }"
7+
system_test_file = File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
8+
if turbo_defined? && options[:system_tests] && File.exist?(system_test_file)
9+
gsub_file(system_test_file, /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }")
1110
end
1211
end
1312

test/integration/user_install_test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ if [[ $(rails -v) > "Rails 8.0.0.beta" ]] ; then
6969
grep -q PasswordsController app/controllers/passwords_controller.rb
7070
fi
7171

72+
# TEST: doesn't fail when not generating system tests
73+
bin/rails generate scaffold memo title:string body:text published:boolean --system-tests=false
74+
grep -q "Show" app/views/memos/index.html.erb
75+
7276
# TEST: presence of the generated file
73-
bin/rails generate scaffold post title:string body:text published:boolean
77+
bin/rails generate scaffold post title:string body:text published:boolean --system-tests=true
7478
grep -q "Show" app/views/posts/index.html.erb
7579

7680
# TEST: the "accept_confirm" system test change was applied cleanly

0 commit comments

Comments
 (0)