Skip to content

Commit 06585ba

Browse files
committed
check Rails configuration before modifying system test
Fixes #559 With this change the scaffold generator no longer assumes the Rails project has system tests enabled.
1 parent ed7d059 commit 06585ba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/generators/test_unit/scaffold/scaffold_generator.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module TestUnit # :nodoc:
44
module Generators # :nodoc:
55
class ScaffoldGenerator < Base # :nodoc:
66
def fix_system_test
7-
if turbo_defined?
7+
if system_tests_enabled? && turbo_defined?
88
gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"),
99
/(click_on.*Destroy this.*)$/,
1010
"accept_confirm { \\1 }"
@@ -16,6 +16,10 @@ def fix_system_test
1616
def turbo_defined?
1717
defined?(Turbo)
1818
end
19+
20+
def system_tests_enabled?
21+
defined?(Rails.configuration.generators) && Rails.configuration.generators.system_tests
22+
end
1923
end
2024
end
2125
end

0 commit comments

Comments
 (0)