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

Allowing string as url argument for expire_action

This commit is contained in:
Thomas von Deyen 2011-12-06 13:05:15 +01:00
parent 81fec5dfc4
commit 0da31a1839
2 changed files with 22 additions and 3 deletions

View file

@ -116,9 +116,8 @@ module ActionController #:nodoc:
def expire_action(options = {}) def expire_action(options = {})
return unless cache_configured? return unless cache_configured?
actions = options[:action] if options.is_a?(Hash) && options[:action].is_a?(Array)
if actions.is_a?(Array) options[:action].each {|action| expire_action(options.merge(:action => action)) }
actions.each {|action| expire_action(options.merge(:action => action)) }
else else
expire_fragment(ActionCachePath.new(self, options, false).path) expire_fragment(ActionCachePath.new(self, options, false).path)
end end

View file

@ -251,6 +251,11 @@ class ActionCachingTestController < CachingController
expire_action :controller => 'action_caching_test', :action => 'index', :format => 'xml' expire_action :controller => 'action_caching_test', :action => 'index', :format => 'xml'
render :nothing => true render :nothing => true
end end
def expire_with_url_string
expire_action url_for(:controller => 'action_caching_test', :action => 'index')
render :nothing => true
end
end end
class MockTime < Time class MockTime < Time
@ -445,6 +450,21 @@ class ActionCacheTest < ActionController::TestCase
assert_not_equal cached_time, @response.body assert_not_equal cached_time, @response.body
end end
def test_cache_expiration_with_url_string
get :index
cached_time = content_to_cache
reset!
@request.request_uri = "/action_caching_test/expire_with_url_string"
get :expire_with_url_string
assert_response :success
reset!
get :index
assert_response :success
assert_not_equal cached_time, @response.body
end
def test_cache_is_scoped_by_subdomain def test_cache_is_scoped_by_subdomain
@request.host = 'jamis.hostname.com' @request.host = 'jamis.hostname.com'
get :index get :index