Don't generate HTML/ERB templates for scaffold controller with --api flag

- Fixes #27591.
This commit is contained in:
Prathamesh Sonpatki 2017-01-07 18:04:48 +05:30
parent 7b13236818
commit b05fec04e9
No known key found for this signature in database
GPG Key ID: 8B90F6B89E2BCB71
3 changed files with 18 additions and 1 deletions

@ -1,3 +1,9 @@
* Don't generate HTML/ERB templates for scaffold controller with `--api` flag.
Fixes #27591.
*Prathamesh Sonpatki*
* Make `Rails.env` fall back to `development` when `RAILS_ENV` and `RACK_ENV` is an empty string.
*Daniel Deng*

@ -20,7 +20,12 @@ def create_controller_files
template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
end
hook_for :template_engine, :test_framework, as: :scaffold
hook_for :template_engine, as: :scaffold do |template_engine|
invoke template_engine unless options.api?
end
hook_for :test_framework, as: :scaffold
# Invoke the helper using the controller name (pluralized)
hook_for :helper, as: :scaffold do |invoked|

@ -230,6 +230,12 @@ def test_api_only_generates_a_proper_api_controller
assert_match(/@user\.destroy/, m)
end
end
assert_no_file "app/views/users/index.html.erb"
assert_no_file "app/views/users/edit.html.erb"
assert_no_file "app/views/users/show.html.erb"
assert_no_file "app/views/users/new.html.erb"
assert_no_file "app/views/users/_form.html.erb"
end
def test_api_controller_tests