From f55ef82321c33a308c64e54c66b45e4fff542efa Mon Sep 17 00:00:00 2001 From: jejacks0n Date: Thu, 3 Jan 2013 20:51:44 -0700 Subject: 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. --- actionpack/CHANGELOG.md | 7 +++++++ actionpack/lib/sprockets/helpers/rails_helper.rb | 4 ++-- actionpack/test/fixtures/sprockets/app/javascripts/extra.js | 1 + actionpack/test/fixtures/sprockets/app/stylesheets/extra.css | 1 + actionpack/test/template/sprockets_helper_test.rb | 5 +++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 5ff1a06c62..b887a5837a 100644 --- a/actionpack/CHANGELOG.md +++ b/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* diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 690c71b472..bc573d8640 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -31,7 +31,7 @@ module Sprockets 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 @@ module Sprockets 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 = {}) diff --git a/actionpack/test/fixtures/sprockets/app/javascripts/extra.js b/actionpack/test/fixtures/sprockets/app/javascripts/extra.js index e69de29bb2..e611d2b129 100644 --- a/actionpack/test/fixtures/sprockets/app/javascripts/extra.js +++ b/actionpack/test/fixtures/sprockets/app/javascripts/extra.js @@ -0,0 +1 @@ +//= require xmlhr diff --git a/actionpack/test/fixtures/sprockets/app/stylesheets/extra.css b/actionpack/test/fixtures/sprockets/app/stylesheets/extra.css index e69de29bb2..2365eaa4cd 100644 --- a/actionpack/test/fixtures/sprockets/app/stylesheets/extra.css +++ b/actionpack/test/fixtures/sprockets/app/stylesheets/extra.css @@ -0,0 +1 @@ +/*= require style */ diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index e944cfaee3..01dd66aa1f 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -266,6 +266,8 @@ class SprocketsHelperTest < ActionView::TestCase javascript_include_tag('/javascripts/application') assert_match %r{\n}, javascript_include_tag(:application) + assert_match %r{\n\n}, + javascript_include_tag(:application, :extra) end test "stylesheet path through asset_path" do @@ -324,6 +326,9 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, stylesheet_link_tag(:application) + assert_match %r{\n\n}, + stylesheet_link_tag(:application, :extra) + assert_match %r{\n}, stylesheet_link_tag(:application, :media => "print") end -- cgit v1.2.3