diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 7d50e7da67..c99aa3c0cd 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -115,6 +115,7 @@ module Rails directory "public/javascripts" else empty_directory_with_gitkeep "public/javascripts" + create_file "public/javascripts/application.js" end end diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 589f7e674a..ad8f523c28 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -40,7 +40,11 @@ module <%= app_const_base %> # config.i18n.default_locale = :de # Add your default javascripts +<% if options[:skip_prototype] -%> + config.action_view.javascript_expansions[:defaults] = [] +<% else -%> # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) +<% end -%> # Configure generators values. Many other options are available, be sure to check the documentation. # config.generators do |g| diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 6a3b5de9de..9d7a976afd 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -129,14 +129,19 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_prototype_and_test_unit_are_added_by_default run_generator + assert_file "config/application.rb", /#\s+config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+%w\(jquery rails\)/ + assert_file "public/javascripts/application.js" assert_file "public/javascripts/prototype.js" + assert_file "public/javascripts/rails.js" assert_file "test" end def test_prototype_and_test_unit_are_skipped_if_required run_generator [destination_root, "--skip-prototype", "--skip-testunit"] + assert_file "config/application.rb", /^\s+config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+\[\]/ + assert_file "public/javascripts/application.js" assert_no_file "public/javascripts/prototype.js" - assert_file "public/javascripts" + assert_no_file "public/javascripts/rails.js" assert_no_file "test" end