diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-05-09 12:36:20 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2012-05-09 12:36:20 -0700 |
commit | f8dae865b5f33bd1846e93aa19dcdb52a5665461 (patch) | |
tree | 3268cc852127fe2433e5b06ba266910b7193b2b2 /actionpack | |
parent | 8f5079f190c849b2fb4de24739af742cc5a9e37b (diff) | |
parent | 0621ecb20bd76a3d294fbbed73e54fe81a3cb6d2 (diff) | |
download | rails-f8dae865b5f33bd1846e93aa19dcdb52a5665461.tar.gz rails-f8dae865b5f33bd1846e93aa19dcdb52a5665461.tar.bz2 rails-f8dae865b5f33bd1846e93aa19dcdb52a5665461.zip |
Merge pull request #6149 from jmbejar/javascript_include_tag_with_not_duplicates
Make sure that javascript_include_tag/stylesheet_link_tag methods don't consider duplicated assets
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 4 | ||||
-rw-r--r-- | actionpack/test/template/sprockets_helper_test.rb | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 3402343494..4e11221842 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.join("\n").html_safe + end.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.join("\n").html_safe + end.uniq.join("\n").html_safe end def asset_path(source, options = {}) diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 1c591bdcc2..fc3c87a72e 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -254,6 +254,9 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{<script src="/assets/jquery.plugin.js" type="text/javascript"></script>}, javascript_include_tag('jquery.plugin', :digest => false) + assert_match %r{\A<script src="/assets/xmlhr-[0-9a-f]+.js" type="text/javascript"></script>\Z}, + javascript_include_tag("xmlhr", "xmlhr") + @config.assets.compile = true @config.assets.debug = true assert_match %r{<script src="/javascripts/application.js" type="text/javascript"></script>}, @@ -301,6 +304,9 @@ class SprocketsHelperTest < ActionView::TestCase 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, :debug => true) + assert_match %r{\A<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\Z}, + stylesheet_link_tag("style", "style") + @config.assets.compile = true @config.assets.debug = true assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />}, |