mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Adds application.js when app is generated with -J and clear javascript_expansions[:defaults]
This commit is contained in:
parent
ea7f1fb026
commit
114fa4d431
3 changed files with 11 additions and 1 deletions
|
@ -115,6 +115,7 @@ module Rails
|
|||
directory "public/javascripts"
|
||||
else
|
||||
empty_directory_with_gitkeep "public/javascripts"
|
||||
create_file "public/javascripts/application.js"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue