From bec8b0a72958e37a3a19946a2f39ce8f119dee3e Mon Sep 17 00:00:00 2001 From: Frederick Cheung Date: Thu, 11 Dec 2008 00:03:49 +0000 Subject: [PATCH] Fix nil error when default javascripts are not present --- .../lib/action_view/helpers/asset_tag_helper.rb | 2 +- actionpack/test/template/asset_tag_helper_test.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 0633d54..9e703be 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -778,7 +778,7 @@ module ActionView def expand_sources if @sources.include?(:all) assets = all_asset_files - ((defaults.dup & assets) + assets).uniq! + ((defaults.dup & assets) + assets).uniq else expanded_sources = validate_sources! expanded_sources << APPLICATION_JS if include_application? diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 7597927..03662a7 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -160,7 +160,12 @@ class AssetTagHelperTest < ActionView::TestCase ENV["RAILS_ASSET_ID"] = "" JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end - + + def test_javascript_include_when_defaults_missing + Dir.expects(:[]).returns(['public/javascripts/foolib.js']) + assert_dom_equal %(), javascript_include_tag(:all) + end + def test_javascript_include_tag_with_given_asset_id ENV["RAILS_ASSET_ID"] = "1" assert_dom_equal(%(\n\n\n\n), javascript_include_tag(:defaults)) -- 1.6.0.1