mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #27604 from prathamesh-sonpatki/dont-generate-erb-views-for-api-scaffold-controller
Don't generate HTML/ERB templates for scaffold controller with --api flag
This commit is contained in:
commit
ee47aab757
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.
|
* Make `Rails.env` fall back to `development` when `RAILS_ENV` and `RACK_ENV` is an empty string.
|
||||||
|
|
||||||
*Daniel Deng*
|
*Daniel Deng*
|
||||||
|
|
|
@ -20,7 +20,12 @@ module Rails
|
||||||
template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
|
template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
|
||||||
end
|
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)
|
# Invoke the helper using the controller name (pluralized)
|
||||||
hook_for :helper, as: :scaffold do |invoked|
|
hook_for :helper, as: :scaffold do |invoked|
|
||||||
|
|
|
@ -230,6 +230,12 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
||||||
assert_match(/@user\.destroy/, m)
|
assert_match(/@user\.destroy/, m)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def test_api_controller_tests
|
def test_api_controller_tests
|
||||||
|
|
Loading…
Reference in a new issue