aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2015-07-23 18:03:40 +0200
committerRobin Dupret <robin.dupret@gmail.com>2015-07-23 19:36:49 +0200
commita120f2716e794f49677804b1e0733c4baa61e96a (patch)
treed25c627c7d4cb9a0d15f74799805f5a40286f0c6 /railties/test
parentce32c9da962a9dd7a894c9a4457db9dd5f5a5a1f (diff)
downloadrails-a120f2716e794f49677804b1e0733c4baa61e96a.tar.gz
rails-a120f2716e794f49677804b1e0733c4baa61e96a.tar.bz2
rails-a120f2716e794f49677804b1e0733c4baa61e96a.zip
Enable the `api_only` option for API plugins' generators
This way, running a generator inside the plugin's directory, files that are not relevant won't be generated (e.g. views or assets). This won't interfere with the application's generators configuration.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/plugin_generator_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index 2a89e2160b..6f5a815173 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -572,6 +572,32 @@ class PluginGeneratorTest < Rails::Generators::TestCase
end
end
+
+ def test_api_generators_configuration_for_api_engines
+ run_generator [destination_root, '--full', '--api']
+
+ assert_file "lib/bukkits/engine.rb" do |content|
+ assert_match "config.generators.api_only = true", content
+ end
+ end
+
+ def test_scaffold_generator_for_mountable_api_plugins
+ run_generator [destination_root, '--mountable', '--api']
+
+ capture(:stdout) do
+ `#{destination_root}/bin/rails g scaffold article`
+ end
+
+ assert_file "app/models/bukkits/article.rb"
+ assert_file "app/controllers/bukkits/articles_controller.rb" do |content|
+ assert_match "only: [:show, :update, :destroy]", content
+ end
+
+ assert_no_directory "app/assets"
+ assert_no_directory "app/helpers"
+ assert_no_directory "app/views"
+ end
+
protected
def action(*args, &block)
silence(:stdout){ generator.send(*args, &block) }