aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/generators_test.rb
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2015-06-11 17:44:06 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2015-06-11 17:44:06 -0300
commit21f7bcbaa7709ed072bb2e1273d25c09eeaa26d9 (patch)
tree14b91132cbe37e1b3bc6c8af41a8804b8163edac /railties/test/application/generators_test.rb
parented7d787e120347ebc97647014a5e1fef7a34c19c (diff)
parent51d5d6252ee093d3fa004abec79319ae8b4c42c4 (diff)
downloadrails-21f7bcbaa7709ed072bb2e1273d25c09eeaa26d9.tar.gz
rails-21f7bcbaa7709ed072bb2e1273d25c09eeaa26d9.tar.bz2
rails-21f7bcbaa7709ed072bb2e1273d25c09eeaa26d9.zip
Merge pull request #19832 from spastorino/rails-api
Rails api
Diffstat (limited to 'railties/test/application/generators_test.rb')
-rw-r--r--railties/test/application/generators_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb
index 78ada58ec8..84cc6e120b 100644
--- a/railties/test/application/generators_test.rb
+++ b/railties/test/application/generators_test.rb
@@ -125,5 +125,40 @@ module ApplicationTests
assert_equal expected, c.generators.options
end
end
+
+ test "api only generators hide assets, helper, js and css namespaces and set api option" do
+ add_to_config <<-RUBY
+ config.api_only = true
+ RUBY
+
+ # Initialize the application
+ require "#{app_path}/config/environment"
+ Rails.application.load_generators
+
+ assert Rails::Generators.hidden_namespaces.include?("assets")
+ assert Rails::Generators.hidden_namespaces.include?("helper")
+ assert Rails::Generators.hidden_namespaces.include?("js")
+ assert Rails::Generators.hidden_namespaces.include?("css")
+ assert Rails::Generators.options[:rails][:api]
+ assert_equal false, Rails::Generators.options[:rails][:assets]
+ assert_equal false, Rails::Generators.options[:rails][:helper]
+ assert_nil Rails::Generators.options[:rails][:template_engine]
+ end
+
+ test "api only generators allow overriding generator options" do
+ add_to_config <<-RUBY
+ config.generators.helper = true
+ config.api_only = true
+ config.generators.template_engine = :my_template
+ RUBY
+
+ # Initialize the application
+ require "#{app_path}/config/environment"
+ Rails.application.load_generators
+
+ assert Rails::Generators.options[:rails][:api]
+ assert Rails::Generators.options[:rails][:helper]
+ assert_equal :my_template, Rails::Generators.options[:rails][:template_engine]
+ end
end
end