From 06585badf8bed12a1f6db25f61b8c1c370af0904 Mon Sep 17 00:00:00 2001 From: robert schultheis Date: Wed, 2 Jul 2025 12:20:23 -0400 Subject: [PATCH] check Rails configuration before modifying system test Fixes https://github.com/rails/tailwindcss-rails/issues/559 With this change the scaffold generator no longer assumes the Rails project has system tests enabled. --- lib/generators/test_unit/scaffold/scaffold_generator.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index ff809b3..9e492ca 100644 --- a/lib/generators/test_unit/scaffold/scaffold_generator.rb +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -4,7 +4,7 @@ module TestUnit # :nodoc: module Generators # :nodoc: class ScaffoldGenerator < Base # :nodoc: def fix_system_test - if turbo_defined? + if system_tests_enabled? && turbo_defined? gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }" @@ -16,6 +16,10 @@ def fix_system_test def turbo_defined? defined?(Turbo) end + + def system_tests_enabled? + defined?(Rails.configuration.generators) && Rails.configuration.generators.system_tests + end end end end