Skip to content

Commit

Permalink
Fixed the AssetTagHelper cache to use the computed asset host as part…
Browse files Browse the repository at this point in the history
… of the cache key instead of just assuming the its a string [#1299 state:fixed]
  • Loading branch information
dhh committed Jan 1, 2009
1 parent d7b7ff0 commit ee701e0
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 5 deletions.
55 changes: 55 additions & 0 deletions actionpack/CHANGELOG
Expand Up @@ -2,6 +2,61 @@

* I18n: translate number_to_human_size. Add storage_units: [Bytes, KB, MB, GB, TB] to your translations. #1448 [Yaroslav Markin]

* 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')
render('other_action') # argument has no '/'
render(:other_action)

# Instead of render(:template => 'controller/action')
render('controller/action') # argument must not begin with a '/', but contain a '/'

# Instead of render(:file => '/Users/lifo/home.html.erb')
render('/Users/lifo/home.html.erb') # argument must begin with a '/'

* Add :prompt option to date/time select helpers. #561 [Sam Oliver]

* Fixed that send_file shouldn't set an etag #1578 [Hongli Lai]

* Allow users to opt out of the spoofing checks in Request#remote_ip. Useful for sites whose traffic regularly triggers false positives. [Darren Boyd]

* Deprecated formatted_polymorphic_url. [Jeremy Kemper]

* Added the option to declare an asset_host as an object that responds to call (see http://github.com/dhh/asset-hosting-with-minimum-ssl for an example) [David Heinemeier Hansson]

* Added support for multiple routes.rb files (useful for plugin engines). This also means that draw will no longer clear the route set, you have to do that by hand (shouldn't make a difference to you unless you're doing some funky stuff) [David Heinemeier Hansson]

* Dropped formatted_* routes in favor of just passing in :format as an option. This cuts resource routes generation in half #1359 [aaronbatalion]

* Remove support for old double-encoded cookies from the cookie store. These values haven't been generated since before 2.1.0, and any users who have visited the app in the intervening 6 months will have had their cookie upgraded. [Michael Koziarski]

* Allow helpers directory to be overridden via ActionController::Base.helpers_dir #1424 [Sam Pohlenz]

* Remove deprecated ActionController::Base#assign_default_content_type_and_charset

* Changed the default of ActionView#render to assume partials instead of files when not given an options hash [David Heinemeier Hansson]. Examples:

# Instead of <%= render :partial => "account" %>
<%= render "account" %>

# Instead of <%= render :partial => "account", :locals => { :account => @buyer } %>
<%= render "account", :account => @buyer %>

# @account is an Account instance, so it uses the RecordIdentifier to replace
# <%= render :partial => "accounts/account", :locals => { :account => @account } %>
<%= render(@account) %>

# @posts is an array of Post instances, so it uses the RecordIdentifier to replace
# <%= render :partial => "posts/post", :collection => @posts %>
<%= render(@posts) %>

* Remove deprecated render_component. Please use the plugin from http://github.com/rails/render_component/tree/master [Pratik Naik]

* Fixed RedCloth and BlueCloth shouldn't preload. Instead just assume that they're available if you want to use textilize and markdown and let autoload require them [David Heinemeier Hansson]
>>>>>>> 49a055d... 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]:actionpack/CHANGELOG

This comment has been minimized.

Copy link
@alloy

alloy Jan 1, 2009

Contributor

Seems like a patch message slipt through.

Happy new year btw! :)



*2.2.2 (November 21st, 2008)*

Expand Down
10 changes: 5 additions & 5 deletions actionpack/lib/action_view/helpers/asset_tag_helper.rb
Expand Up @@ -538,12 +538,12 @@ def initialize(template, controller, source, include_host = true)
@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

Expand Down
20 changes: 20 additions & 0 deletions actionpack/test/template/asset_tag_helper_test.rb
Expand Up @@ -281,6 +281,26 @@ def test_should_not_modify_source_string
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'
Expand Down

1 comment on commit ee701e0

@lifo
Copy link
Member

@lifo lifo commented on ee701e0 Jan 1, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird…there’s 49a055dff639164435dfb71bf18d695970eedac9 too

Please sign in to comment.