Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed that setting RAILS_ASSET_ID to "" should not add a trailing sla…

…sh after assets (closes #6454) [BobSilva/chrismear]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5335 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit afd288cf8141eca321061cb00879f52108d68013 1 parent ba5591f
David Heinemeier Hansson dhh authored
2  actionpack/CHANGELOG
View
@@ -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
12 actionpack/lib/action_view/helpers/asset_tag_helper.rb
View
@@ -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
2  actionpack/lib/action_view/helpers/capture_helper.rb
View
@@ -89,7 +89,7 @@ def capture(*args, &block)
# named @@content_for_#{name_of_the_content_block}@. So <tt><%= content_for('footer') %></tt>
# would be avaiable as <tt><%= @content_for_footer %></tt>. The preferred notation now is
# <tt><%= yield :footer %></tt>.
- def content_for(name, &block)
+ def content_for(name, content = nil, &block)
eval "@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)"
end
9 actionpack/test/template/asset_tag_helper_test.rb
View
@@ -70,7 +70,8 @@ def teardown
%(stylesheet_link_tag("/dir/file")) => %(<link href="/dir/file.css" media="screen" rel="Stylesheet" type="text/css" />),
%(stylesheet_link_tag("dir/file")) => %(<link href="/stylesheets/dir/file.css" media="screen" rel="Stylesheet" type="text/css" />),
%(stylesheet_link_tag("style", :media => "all")) => %(<link href="/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" />),
- %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />)
+ %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />),
+ %(stylesheet_link_tag("http://www.example.com/styles/style")) => %(<link href="http://www.example.com/styles/style.css" media="screen" rel="Stylesheet" type="text/css" />)
}
ImagePathToTag = {
@@ -141,6 +142,12 @@ def test_preset_asset_id
assert_equal %(<img alt="Rails" src="/images/rails.png?4500" />), 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 %(<img alt="Rails" src="/images/rails.png" />), 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'
Please sign in to comment.
Something went wrong with that request. Please try again.