From 4ddf6ccad0a8218af4ccd9c40250483f83934c30 Mon Sep 17 00:00:00 2001 From: "Ruy R." <108208+ruyrocha@users.noreply.github.com> Date: Sun, 28 Jan 2024 20:38:04 -0300 Subject: [PATCH] Skip CSS when creating APIs. Update CHANGELOG. Address requested changes. --- railties/CHANGELOG.md | 4 ++++ railties/lib/rails/generators/app_base.rb | 1 + railties/test/generators/api_app_generator_test.rb | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 4a6930177d3..e29c9c8d28a 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Skip CSS when generating APIs. + + *Ruy Rocha* + * Rails console now indicates application name and the current Rails environment: ```txt diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 2c2d3cd0e80..9116579ad0a 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -599,6 +599,7 @@ module Rails end def css_gemfile_entry + return if options[:api] return unless options[:css] if !using_js_runtime? && options[:css] == "tailwind" diff --git a/railties/test/generators/api_app_generator_test.rb b/railties/test/generators/api_app_generator_test.rb index c406b4e03c1..1f6967cb3b5 100644 --- a/railties/test/generators/api_app_generator_test.rb +++ b/railties/test/generators/api_app_generator_test.rb @@ -94,6 +94,18 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase assert_no_directory "app/views" end + def test_generator_skip_css + run_generator [destination_root, "--api", "--css=tailwind"] + + assert_file "Gemfile" do |content| + assert_no_match(%r/gem "tailwindcss-rails"/, content) + end + + assert_no_file "app/views/layouts/application.html.erb" do |content| + assert_no_match(/tailwind/, content) + end + end + def test_app_update_does_not_generate_unnecessary_config_files run_generator