Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds application.js when app is generated with -J and clear javascrip…

…t_expansions[:defaults]
  • Loading branch information...
commit 114fa4d43121cd05fc18a8449a4d1abd92978a72 1 parent ea7f1fb
@spastorino spastorino authored tenderlove committed
View
1  railties/lib/rails/generators/rails/app/app_generator.rb
@@ -115,6 +115,7 @@ def javascripts
directory "public/javascripts"
else
empty_directory_with_gitkeep "public/javascripts"
+ create_file "public/javascripts/application.js"
end
end
View
4 railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -40,7 +40,11 @@ class Application < Rails::Application
# 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|
View
7 railties/test/generators/app_generator_test.rb
@@ -129,14 +129,19 @@ def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
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
Please sign in to comment.
Something went wrong with that request. Please try again.