From b6cb944e46bb7d042273bc4a3fed40cf28ab1288 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 5 Jul 2025 17:17:10 -0400 Subject: [PATCH] Gracefully handle --skip-system-test Fixes #559 --- .../test_unit/scaffold/scaffold_generator.rb | 2 +- test/integration/user_install_test.sh | 58 +++++++++++++------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/lib/generators/test_unit/scaffold/scaffold_generator.rb b/lib/generators/test_unit/scaffold/scaffold_generator.rb index ff809b3..c9f1647 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 turbo_defined? && options[:system_tests] gsub_file File.join("test/system", class_path, "#{file_name.pluralize}_test.rb"), /(click_on.*Destroy this.*)$/, "accept_confirm { \\1 }" diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index bfd7a87..7bd3b63 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -11,34 +11,41 @@ bundle remove actionmailer || true bundle remove rails || true bundle add rails --skip-install ${RAILSOPTS:-} bundle install --prefer-local +bundle exec rails -v # do our work a directory with spaces in the name (#176, #184) rm -rf "My Workspace" mkdir "My Workspace" pushd "My Workspace" -# create a rails app -bundle exec rails -v +function prepare_deps { + # make sure to use the same version of rails (e.g., install from git source if necessary) + bundle remove rails --skip-install + bundle add rails --skip-install ${RAILSOPTS:-} + + # use the tailwindcss-rails under test + bundle add tailwindcss-rails --skip-install --path="../.." + bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-} + bundle install --prefer-local + bundle show --paths | fgrep tailwind + bundle binstubs --all +} + +function install_tailwindcss { + # install tailwindcss + bin/rails tailwindcss:install + + # TEST: tailwind was installed correctly + grep -q "
> Rakefile @@ -73,4 +80,17 @@ grep -q "py-2" app/assets/builds/tailwind.css # TEST: contents include application.css directives grep -q "#abc12399" app/assets/builds/tailwind.css +# Application variation #2 ---------------------------------------- +popd +bundle exec rails new test-install2 --skip-bundle --skip-system-test +pushd test-install2 + +prepare_deps +install_tailwindcss + +# TEST: presence of the generated file +# TEST: nothing blew up without system tests, https://github.com/rails/tailwindcss-rails/issues/559 +bin/rails generate scaffold post title:string body:text published:boolean +grep -q "Show" app/views/posts/index.html.erb + echo "OK"