Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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...
commit f55ef82321c33a308c64e54c66b45e4fff542efa 1 parent 11f5deb
@jejacks0n jejacks0n authored
View
7 actionpack/CHANGELOG.md
@@ -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.
@@ -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*
View
4 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -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)
@@ -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 = {})
View
1  actionpack/test/fixtures/sprockets/app/javascripts/extra.js
@@ -0,0 +1 @@
+//= require xmlhr
View
1  actionpack/test/fixtures/sprockets/app/stylesheets/extra.css
@@ -0,0 +1 @@
+/*= require style */
View
5 actionpack/test/template/sprockets_helper_test.rb
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.