Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes issue where duplicate assets can be required with sprockets.
- addresses the problem by calling flatten on asset array before calling uniq.
- adds note to CHANGELOG.
  • Loading branch information
jejacks0n committed Jan 10, 2013
1 parent 11f5deb commit f55ef82
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions actionpack/CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@
*Sam Ruby + Carlos Antonio da Silva*

* Do not append second slash to `root_url` when using `trailing_slash: true`

* Do not append second slash to root_url when using `trailing_slash: true`

Fix #8700.
Backport #8701.

Expand All @@ -17,6 +20,10 @@

*Yves Senn*

* Fixes issue where duplicate assets can be required with sprockets.

*Jeremy Jackson*

* Fix a bug in `content_tag_for` that prevents it for work without a block.

*Jasl*
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/sprockets/helpers/rails_helper.rb
Expand Up @@ -31,7 +31,7 @@ def javascript_include_tag(*sources)
else
super(source.to_s, { :src => path_to_asset(source, :ext => 'js', :body => body, :digest => digest) }.merge!(options))
end
end.uniq.join("\n").html_safe
end.flatten.uniq.join("\n").html_safe
end

def stylesheet_link_tag(*sources)
Expand All @@ -48,7 +48,7 @@ def stylesheet_link_tag(*sources)
else
super(source.to_s, { :href => path_to_asset(source, :ext => 'css', :body => body, :protocol => :request, :digest => digest) }.merge!(options))
end
end.uniq.join("\n").html_safe
end.flatten.uniq.join("\n").html_safe
end

def asset_path(source, options = {})
Expand Down
@@ -0,0 +1 @@
//= require xmlhr
@@ -0,0 +1 @@
/*= require style */
5 changes: 5 additions & 0 deletions actionpack/test/template/sprockets_helper_test.rb
Expand Up @@ -266,6 +266,8 @@ def compute_host(source, request, options = {})
javascript_include_tag('/javascripts/application')
assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>},
javascript_include_tag(:application)
assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/extra-[0-9a-f]+.js\?body=1" type="text/javascript"></script>},
javascript_include_tag(:application, :extra)
end

test "stylesheet path through asset_path" do
Expand Down Expand Up @@ -324,6 +326,9 @@ def compute_host(source, request, options = {})
assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
stylesheet_link_tag(:application)

assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/extra-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
stylesheet_link_tag(:application, :extra)

assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="print" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="print" rel="stylesheet" type="text/css" />},
stylesheet_link_tag(:application, :media => "print")
end
Expand Down

0 comments on commit f55ef82

Please sign in to comment.