提交 0e261080 编写于 作者: G Guillermo Iguaran

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.
上级 7e748594
......@@ -389,9 +389,13 @@ def delete_app_helpers_if_api_option
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
......
......@@ -63,6 +63,23 @@ def test_generator_if_skip_action_cable_is_given
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册