提交 453f2221 编写于 作者: J José Valim

Merge pull request #2005 from acroca/master

Fixing asset number for asset_path with %d to be consistent in ruby 1.9
......@@ -111,7 +111,8 @@ def compute_asset_host(source)
args << current_request if (arity > 1 || arity < 0) && has_request?
host.call(*args)
else
(host =~ /%d/) ? host % (source.hash % 4) : host
source_num = source.bytes.sum
(host =~ /%d/) ? host % (source_num % 4) : host
end
end
end
......
......@@ -689,9 +689,9 @@ def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory
@controller.config.asset_host = 'http://a%d.example.com'
config.perform_caching = true
hash = '/javascripts/cache/money.js'.hash % 4
number = '/javascripts/cache/money.js'.bytes.sum % 4
assert_dom_equal(
%(<script src="http://a#{hash}.example.com/javascripts/cache/money.js" type="text/javascript"></script>),
%(<script src="http://a#{number}.example.com/javascripts/cache/money.js" type="text/javascript"></script>),
javascript_include_tag(:all, :cache => "cache/money")
)
......@@ -1129,6 +1129,7 @@ def test_should_ignore_asset_host_on_scheme_relative_url
end
def test_should_wildcard_asset_host_between_zero_and_four
String.any_instance.expects(:hash).times(0)
@controller.config.asset_host = 'http://a%d.example.com'
assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png'))
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册