Skip to content

Commit

Permalink
Merge pull request #50907 from ruyrocha/fix/skip-css-on-apis
Browse files Browse the repository at this point in the history
Skip CSS when creating APIs.
  • Loading branch information
rafaelfranca committed Jan 29, 2024
2 parents 6b96010 + 4ddf6cc commit 44e2bc2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Skip CSS when generating APIs.

*Ruy Rocha*

* Rails console now indicates application name and the current Rails environment:

```txt
Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/generators/app_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ def dockerfile_deploy_packages
end

def css_gemfile_entry
return if options[:api]
return unless options[:css]

if !using_js_runtime? && options[:css] == "tailwind"
Expand Down
12 changes: 12 additions & 0 deletions railties/test/generators/api_app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ def test_generator_if_skip_action_mailer_is_given
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

Expand Down

0 comments on commit 44e2bc2

Please sign in to comment.