diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2009-01-01 18:12:49 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-01-01 18:12:49 +0100 |
commit | 49a055dff639164435dfb71bf18d695970eedac9 (patch) | |
tree | 3c20c4efad47cad949d6d2ef5c236bdd502bf1dc | |
parent | 3b92b141fd0759476690a174d5e2f8f0f2d9f1b7 (diff) | |
download | rails-49a055dff639164435dfb71bf18d695970eedac9.tar.gz rails-49a055dff639164435dfb71bf18d695970eedac9.tar.bz2 rails-49a055dff639164435dfb71bf18d695970eedac9.zip |
Fixed the AssetTagHelper cache to use the computed asset host as part of the cache key instead of just assuming the its a string [#1299 state:committed]
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 10 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 20 |
3 files changed, 27 insertions, 5 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index a8abf48441..44790605b2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *2.3.0 [Edge]* +* Fixed the AssetTagHelper cache to use the computed asset host as part of the cache key instead of just assuming the its a string #1299 [DHH] + * Make ActionController#render(string) work as a shortcut for render :file/:template/:action => string. [#1435] [Pratik Naik] Examples: # Instead of render(:action => 'other_action') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 0633d5414e..79b1cdbc48 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -545,12 +545,12 @@ module ActionView @source = source @include_host = include_host @cache_key = if controller.respond_to?(:request) - [self.class.name,controller.request.protocol, - ActionController::Base.asset_host, - ActionController::Base.relative_url_root, - source, include_host] + [ self.class.name,controller.request.protocol, + compute_asset_host(source), + ActionController::Base.relative_url_root, + source, include_host ] else - [self.class.name,ActionController::Base.asset_host, source, include_host] + [ self.class.name, compute_asset_host(source), source, include_host ] end end diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 7597927f6d..41e7125e01 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -281,6 +281,26 @@ class AssetTagHelperTest < ActionView::TestCase assert_equal copy, source end + def test_caching_image_path_with_caching_and_proc_asset_host_using_request + ENV['RAILS_ASSET_ID'] = '' + ActionController::Base.asset_host = Proc.new do |source, request| + if request.ssl? + "#{request.protocol}#{request.host_with_port}" + else + "#{request.protocol}assets#{source.length}.example.com" + end + end + + ActionController::Base.perform_caching = true + + + @controller.request.stubs(:ssl?).returns(false) + assert_equal "http://assets15.example.com/images/xml.png", image_path("xml.png") + + @controller.request.stubs(:ssl?).returns(true) + assert_equal "http://localhost/images/xml.png", image_path("xml.png") + end + def test_caching_javascript_include_tag_when_caching_on ENV["RAILS_ASSET_ID"] = "" ActionController::Base.asset_host = 'http://a0.example.com' |