From f6a6b51ae551b7f936e974cba3ad4b30422d6804 Mon Sep 17 00:00:00 2001 From: Albert Callarisa Roca Date: Fri, 8 Jul 2011 00:10:20 +0800 Subject: [PATCH] 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 --- actionpack/lib/action_view/asset_paths.rb | 3 ++- actionpack/test/template/asset_tag_helper_test.rb | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_view/asset_paths.rb b/actionpack/lib/action_view/asset_paths.rb index 4dd02755d3..77a8c5322f 100644 --- a/actionpack/lib/action_view/asset_paths.rb +++ b/actionpack/lib/action_view/asset_paths.rb @@ -111,7 +111,8 @@ module ActionView 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 diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index df61901b44..59e7ac144b 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -689,9 +689,9 @@ class AssetTagHelperTest < ActionView::TestCase @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( - %(), + %(), javascript_include_tag(:all, :cache => "cache/money") ) @@ -1129,6 +1129,7 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase 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