diff options
Diffstat (limited to 'railties/test/generators_test.rb')
-rw-r--r-- | railties/test/generators_test.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 60e7e57a91..9e7ec86fdf 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -213,4 +213,55 @@ class GeneratorsTest < Rails::Generators::TestCase Rails::Generators.hide_namespace("special:namespace") assert Rails::Generators.hidden_namespaces.include?("special:namespace") end + + def test_http_only_hides_generators + generators = %w(assets js css session_migration) + + generators.each do |generator| + assert !Rails::Generators.hidden_namespaces.include?(generator) + end + + with_http_only! do + generators.each do |generator| + assert Rails::Generators.hidden_namespaces.include?(generator), + "http only should hide #{generator} generator" + end + end + end + + def test_http_only_enables_http_option + options = Rails::Generators.options[:rails] + + assert !options[:http], "http option should be disabled by default" + + with_http_only! do + assert options[:http], "http only should enable generator http option" + end + end + + def test_http_only_disables_template_and_helper_and_assets_options + options = Rails::Generators.options[:rails] + disable_options = [:assets, :helper, :javascripts, :javascript_engine, + :stylesheets, :stylesheet_engine, :template_engine] + + disable_options.each do |disable_option| + assert options[disable_option], "without http only should have generator option #{disable_option} enabled" + end + + with_http_only! do + disable_options.each do |disable_option| + assert !options[disable_option], "http only should have generator option #{disable_option} disabled" + end + end + end + + private + + def with_http_only! + Rails::Generators.http_only! + yield + ensure + Rails::Generators.instance_variable_set(:@hidden_namespaces, nil) + Rails::Generators.instance_variable_set(:@options, nil) + end end |