mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't generate HTML/ERB templates for scaffold controller with --api flag
- Fixes #27591.
This commit is contained in:
parent
7b13236818
commit
b05fec04e9
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 @@ module Rails
|
|||
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 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue