Skip to content

Commit

Permalink
Merge pull request rails#3876 from tvdeyen/string_as_url_for_expire_a…
Browse files Browse the repository at this point in the history
…ction

Allow string as url for expire_action
  • Loading branch information
josevalim committed Dec 6, 2011
2 parents 81fec5d + 0da31a1 commit d722eb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 2 additions & 3 deletions actionpack/lib/action_controller/caching/actions.rb
Expand Up @@ -116,9 +116,8 @@ def _save_fragment(name, options)
def expire_action(options = {})
return unless cache_configured?

actions = options[:action]
if actions.is_a?(Array)
actions.each {|action| expire_action(options.merge(:action => action)) }
if options.is_a?(Hash) && options[:action].is_a?(Array)
options[:action].each {|action| expire_action(options.merge(:action => action)) }
else
expire_fragment(ActionCachePath.new(self, options, false).path)
end
Expand Down
20 changes: 20 additions & 0 deletions actionpack/test/controller/caching_test.rb
Expand Up @@ -251,6 +251,11 @@ def expire_xml
expire_action :controller => 'action_caching_test', :action => 'index', :format => 'xml'
render :nothing => true
end

def expire_with_url_string
expire_action url_for(:controller => 'action_caching_test', :action => 'index')
render :nothing => true
end
end

class MockTime < Time
Expand Down Expand Up @@ -445,6 +450,21 @@ def test_cache_expiration_isnt_affected_by_request_format
assert_not_equal cached_time, @response.body
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
@request.host = 'jamis.hostname.com'
get :index
Expand Down

0 comments on commit d722eb3

Please sign in to comment.