diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2015-07-23 17:58:02 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2015-07-23 18:27:18 +0200 |
commit | e3cfd5b174f37146b81026c0d1856b672bd6bbec (patch) | |
tree | d65f8c4574b1f05794644f63bb5d639984698228 | |
parent | 67863aa8440805628477647e1015372d11913ca7 (diff) | |
download | rails-e3cfd5b174f37146b81026c0d1856b672bd6bbec.tar.gz rails-e3cfd5b174f37146b81026c0d1856b672bd6bbec.tar.bz2 rails-e3cfd5b174f37146b81026c0d1856b672bd6bbec.zip |
Make ApplicationController inherit from AC::API for API plugins
-rw-r--r-- | railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt | 2 | ||||
-rw-r--r-- | railties/test/generators/plugin_generator_test.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt index 7157e48c42..7fe4e5034d 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt @@ -1,5 +1,5 @@ <%= wrap_in_modules <<-rb.strip_heredoc - class ApplicationController < ActionController::Base + class ApplicationController < ActionController::#{api? ? "API" : "Base"} end rb %> diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 2f6c66cade..86a776f840 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -556,6 +556,14 @@ class PluginGeneratorTest < Rails::Generators::TestCase end end + def test_application_controller_parent_for_mountable_api_plugins + run_generator [destination_root, '--mountable', '--api'] + + assert_file "app/controllers/bukkits/application_controller.rb" do |content| + assert_match "ApplicationController < ActionController::API", content + end + end + protected def action(*args, &block) silence(:stdout){ generator.send(*args, &block) } |