diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 8ed01f39e99d06f00719bddf975ebc857ee30013..04bfdd4c7971f7e6b2e7fca5e916afd369495d7f 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that setting RAILS_ASSET_ID to "" should not add a trailing slash after assets #6454 [BobSilva/chrismear]
+
* Force *_url named routes to show the host in ActionView [Rick]
<%= url_for ... %> # no host
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 93f04968f99dacd86b5e6dec2144305aa1e1a224..086880b06d174d3b9e35baa7b8bf586aa4e662c1 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -159,11 +159,13 @@ def image_tag(source, options = {})
private
def compute_public_path(source, dir, ext)
source = source.dup
- source = "/#{dir}/#{source}" unless source.first == "/" || source.include?(":")
- source << ".#{ext}" unless source.split("/").last.include?(".")
- source << '?' + rails_asset_id(source) if defined?(RAILS_ROOT) && %r{^[-a-z]+://} !~ source
- source = "#{@controller.request.relative_url_root}#{source}" unless %r{^[-a-z]+://} =~ source
- source = ActionController::Base.asset_host + source unless source.include?(":")
+ source << ".#{ext}" if File.extname(source).blank?
+ unless source =~ %r{^[-a-z]+://}
+ source = "/#{dir}/#{source}" unless source[0] == ?/
+ asset_id = rails_asset_id(source)
+ source << '?' + asset_id if defined?(RAILS_ROOT) and not asset_id.blank?
+ source = "#{ActionController::Base.asset_host}#{@controller.request.relative_url_root}#{source}"
+ end
source
end
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index 28b3e29967a4f2fdfc63707aac60cf2bd70dcfd1..497ce093ebda2e09950b6aabd3363d14d6a9ebb0 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -89,7 +89,7 @@ def capture(*args, &block)
# named @@content_for_#{name_of_the_content_block}@. So <%= content_for('footer') %>
# would be avaiable as <%= @content_for_footer %>. The preferred notation now is
# <%= yield :footer %>.
- def content_for(name, &block)
+ def content_for(name, content = nil, &block)
eval "@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)"
end
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index e8320291fe1c6173af549178a0883ca8ef1bf064..4b941921cf9c51713a2592dce53964c8cbce3170 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -70,7 +70,8 @@ def teardown
%(stylesheet_link_tag("/dir/file")) => %(),
%(stylesheet_link_tag("dir/file")) => %(),
%(stylesheet_link_tag("style", :media => "all")) => %(),
- %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(\n)
+ %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(\n),
+ %(stylesheet_link_tag("http://www.example.com/styles/style")) => %()
}
ImagePathToTag = {
@@ -141,6 +142,12 @@ def test_preset_asset_id
assert_equal %(
), image_tag("rails.png")
end
+ def test_preset_empty_asset_id
+ Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/")
+ ENV["RAILS_ASSET_ID"] = ""
+ assert_equal %(
), image_tag("rails.png")
+ end
+
def test_url_dup_image_tag
Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/")
img_url = '/images/rails.png'