Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

This can make make included javascripts/stylesheets from expansions t…

…o be duplicated

or grow forever if you call register_*_expansion more than once

Fix a Regression introduced here 55b13c5
  • Loading branch information...
commit 70dba7414b60a21797b7862b0edf89d2630e1897 1 parent 053031b
Santiago Pastorino spastorino authored
6 actionpack/lib/action_view/helpers/asset_tag_helper.rb
View
@@ -376,8 +376,7 @@ def javascript_include_tag(*sources)
# <script type="text/javascript" src="/javascripts/tail.js"></script>
def self.register_javascript_expansion(expansions)
expansions.each do |key, values|
- @@javascript_expansions[key] ||= []
- @@javascript_expansions[key] += Array(values)
+ @@javascript_expansions[key] = (@@javascript_expansions[key] || []) | Array(values)
end
end
@@ -394,8 +393,7 @@ def self.register_javascript_expansion(expansions)
# <link href="/stylesheets/tail.css" media="screen" rel="stylesheet" type="text/css" />
def self.register_stylesheet_expansion(expansions)
expansions.each do |key, values|
- @@stylesheet_expansions[key] ||= []
- @@stylesheet_expansions[key] += Array(values)
+ @@stylesheet_expansions[key] = (@@stylesheet_expansions[key] || []) | Array(values)
end
end
2  actionpack/test/template/asset_tag_helper_test.rb
View
@@ -278,6 +278,7 @@ def test_registering_javascript_expansions_merges_with_existing_expansions
ENV["RAILS_ASSET_ID"] = ""
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :can_merge => ['bank']
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :can_merge => ['robber']
+ ActionView::Helpers::AssetTagHelper::register_javascript_expansion :can_merge => ['bank']
assert_dom_equal %(<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>), javascript_include_tag(:can_merge)
end
@@ -351,6 +352,7 @@ def test_registering_stylesheet_expansions_merges_with_existing_expansions
ENV["RAILS_ASSET_ID"] = ""
ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['bank']
ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['robber']
+ ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['bank']
assert_dom_equal %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag(:can_merge)
end
Please sign in to comment.
Something went wrong with that request. Please try again.