Skip to content

add accept_confirm if turbo is available so system tests don't fail. fixes #519 #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/generators/tailwindcss/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 21 additions & 0 deletions lib/generators/test_unit/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/user_install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down