Skip to content
This repository
Browse code

Merge pull request #3876 from tvdeyen/string_as_url_for_expire_action

Allow string as url for expire_action
  • Loading branch information...
commit d722eb3b049b18da602a36b6dfd1c69945b9fb0d 2 parents 81fec5d + 0da31a1
José Valim authored December 06, 2011
5  actionpack/lib/action_controller/caching/actions.rb
@@ -116,9 +116,8 @@ def _save_fragment(name, options)
116 116
       def expire_action(options = {})
117 117
         return unless cache_configured?
118 118
 
119  
-        actions = options[:action]
120  
-        if actions.is_a?(Array)
121  
-          actions.each {|action| expire_action(options.merge(:action => action)) }
  119
+        if options.is_a?(Hash) && options[:action].is_a?(Array)
  120
+          options[:action].each {|action| expire_action(options.merge(:action => action)) }
122 121
         else
123 122
           expire_fragment(ActionCachePath.new(self, options, false).path)
124 123
         end
20  actionpack/test/controller/caching_test.rb
@@ -251,6 +251,11 @@ def expire_xml
251 251
     expire_action :controller => 'action_caching_test', :action => 'index', :format => 'xml'
252 252
     render :nothing => true
253 253
   end
  254
+
  255
+  def expire_with_url_string
  256
+    expire_action url_for(:controller => 'action_caching_test', :action => 'index')
  257
+    render :nothing => true
  258
+  end
254 259
 end
255 260
 
256 261
 class MockTime < Time
@@ -445,6 +450,21 @@ def test_cache_expiration_isnt_affected_by_request_format
445 450
     assert_not_equal cached_time, @response.body
446 451
   end
447 452
 
  453
+  def test_cache_expiration_with_url_string
  454
+    get :index
  455
+    cached_time = content_to_cache
  456
+    reset!
  457
+
  458
+    @request.request_uri = "/action_caching_test/expire_with_url_string"
  459
+    get :expire_with_url_string
  460
+    assert_response :success
  461
+    reset!
  462
+
  463
+    get :index
  464
+    assert_response :success
  465
+    assert_not_equal cached_time, @response.body
  466
+  end
  467
+
448 468
   def test_cache_is_scoped_by_subdomain
449 469
     @request.host = 'jamis.hostname.com'
450 470
     get :index

0 notes on commit d722eb3

Please sign in to comment.
Something went wrong with that request. Please try again.