diff --git a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb index 39c2da1f..8748210d 100644 --- a/lib/generators/tailwindcss/scaffold/scaffold_generator.rb +++ b/lib/generators/tailwindcss/scaffold/scaffold_generator.rb @@ -1,5 +1,6 @@ require "rails/generators/erb/scaffold/scaffold_generator" require "rails/generators/resource_helpers" +require File.expand_path("../../test_unit/scaffold/scaffold_generator.rb", __dir__) module Tailwindcss module Generators diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb new file mode 100644 index 00000000..ff809b32 --- /dev/null +++ b/lib/generators/test_unit/scaffold/scaffold_generator.rb @@ -0,0 +1,21 @@ +require "rails/generators/test_unit/scaffold/scaffold_generator" + +module TestUnit # :nodoc: + module Generators # :nodoc: + class ScaffoldGenerator < Base # :nodoc: + def fix_system_test + if turbo_defined? + gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), + /(click_on.*Destroy this.*)$/, + "accept_confirm { \\1 }" + end + end + + private + + def turbo_defined? + defined?(Turbo) + end + end + end +end diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index 6f4ca301..bfd7a87c 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -63,6 +63,9 @@ fi bin/rails generate scaffold post title:string body:text published:boolean grep -q "Show" app/views/posts/index.html.erb +# TEST: the "accept_confirm" system test change was applied cleanly +grep -q "accept_confirm { click_on \"Destroy this post\"" test/system/posts_test.rb + # TEST: contents of the css file bin/rails tailwindcss:build[verbose] grep -q "py-2" app/assets/builds/tailwind.css