Skip to content

Commit

Permalink
Make sure that javascript_include_tag/stylesheet_link_tag methods
Browse files Browse the repository at this point in the history
discard repeated assets
  • Loading branch information
jmbejar committed May 9, 2012
1 parent 440eece commit 0044127
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sprockets/rails/helpers/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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.join("\n").html_safe
end.uniq.join("\n").html_safe
end

def stylesheet_link_tag(*sources)
Expand All @@ -49,7 +49,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.join("\n").html_safe
end.uniq.join("\n").html_safe
end

def asset_path(source, options = {})
Expand Down
6 changes: 6 additions & 0 deletions test/sprockets_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def compute_host(source, request, options = {})
assert_match %r{<script src="/assets/jquery.plugin.js"></script>},
javascript_include_tag('jquery.plugin', :digest => false)

assert_match %r{\A<script src="/assets/xmlhr-[0-9a-f]+.js"></script>\Z},
javascript_include_tag("xmlhr", "xmlhr")

@config.assets.compile = true
@config.assets.debug = true
assert_match %r{<script src="/javascripts/application.js"></script>},
Expand Down Expand Up @@ -298,6 +301,9 @@ def compute_host(source, request, options = {})
assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" />},
stylesheet_link_tag(:application, :debug => true)

assert_match %r{\A<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" />\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" />},
Expand Down

0 comments on commit 0044127

Please sign in to comment.