1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Using the sum of bytes instead the hash of the path when replacing the wildcard of the assets path because in ruby 1.9 is not consistent

This commit is contained in:
Albert Callarisa Roca 2011-07-08 00:10:20 +08:00
parent 298a0834e1
commit f6a6b51ae5
2 changed files with 5 additions and 3 deletions

View file

@ -111,7 +111,8 @@ module ActionView
args << current_request if (arity > 1 || arity < 0) && has_request? args << current_request if (arity > 1 || arity < 0) && has_request?
host.call(*args) host.call(*args)
else else
(host =~ /%d/) ? host % (source.hash % 4) : host source_num = source.bytes.sum
(host =~ /%d/) ? host % (source_num % 4) : host
end end
end end
end end

View file

@ -689,9 +689,9 @@ class AssetTagHelperTest < ActionView::TestCase
@controller.config.asset_host = 'http://a%d.example.com' @controller.config.asset_host = 'http://a%d.example.com'
config.perform_caching = true config.perform_caching = true
hash = '/javascripts/cache/money.js'.hash % 4 number = '/javascripts/cache/money.js'.bytes.sum % 4
assert_dom_equal( 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") javascript_include_tag(:all, :cache => "cache/money")
) )
@ -1129,6 +1129,7 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase
end end
def test_should_wildcard_asset_host_between_zero_and_four 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' @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')) assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png'))
end end