1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't generate empty app/views folder when --api and --skip-action-mailer are used together

The purpose of keeping app/views folder in API apps is that it's used for
mailer views so doesn't makes sense to keep it when Action Mailer is skipped.
This commit is contained in:
Guillermo Iguaran 2018-02-18 16:55:03 -05:00
parent 6cc000c34c
commit 185e6daa3f
2 changed files with 23 additions and 2 deletions

View file

@ -389,9 +389,13 @@ module Rails
end
end
def delete_application_layout_file_if_api_option
def delete_app_views_if_api_option
if options[:api]
remove_file "app/views/layouts/application.html.erb"
if options[:skip_action_mailer]
remove_dir "app/views"
else
remove_file "app/views/layouts/application.html.erb"
end
end
end

View file

@ -63,6 +63,23 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase
end
end
def test_generator_if_skip_action_cable_is_given
run_generator [destination_root, "--api", "--skip-action-mailer"]
assert_file "config/application.rb", /#\s+require\s+["']action_mailer\/railtie["']/
assert_file "config/environments/development.rb" do |content|
assert_no_match(/config\.action_mailer/, content)
end
assert_file "config/environments/test.rb" do |content|
assert_no_match(/config\.action_mailer/, content)
end
assert_file "config/environments/production.rb" do |content|
assert_no_match(/config\.action_mailer/, content)
end
assert_no_directory "app/mailers"
assert_no_directory "test/mailers"
assert_no_directory "app/views"
end
def test_app_update_does_not_generate_unnecessary_config_files
run_generator