public
Description: A Rails plugin that lets you embed actions in your views (with caching and response_to support)
Homepage: http://github.com/sd/embedded-actions/wikis/home
Clone URL: git://github.com/sd/embedded-actions.git
Search Repo:
Fixed caching for controllers that inherit from other controllers
sd (author)
Mon May 19 12:09:29 -0700 2008
commit  3fd53ec3f093dc63dba262ecbb5c5ed281054a39
tree    35c64e8aad10b3e99d2cda0cbb7e731ca37d73f2
parent  c6e9b659e2255e7cbaaa3dba7786db7750d0dc22
...
33
34
35
36
37
 
 
 
 
 
 
 
38
39
40
...
33
34
35
 
 
36
37
38
39
40
41
42
43
44
45
0
@@ -33,8 +33,13 @@ module ActionController
0
         cache_this_instance = options[:params] && options[:params].delete(:caching) # the rest of the request processing code doesn't have to know about this option
0
         return false unless self.perform_caching
0
     
0
- if embedded_class(options).cached_embedded["#{embedded_class(options).controller_path}/#{options[:action]}".to_sym]
0
- return true unless cache_this_instance == false
0
+ controller_class = embedded_class(options)
0
+ while controller_class
0
+ if controller_class.cached_embedded["#{controller_class.controller_path}/#{options[:action]}".to_sym]
0
+ return true unless cache_this_instance == false
0
+ end
0
+ controller_class = controller_class.superclass
0
+ controller_class = nil unless controller_class.respond_to? :controller_path
0
         end
0
 
0
         return cache_this_instance
...
18
19
20
 
21
22
23
 
24
25
26
 
27
28
29
...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -18,12 +18,15 @@ class TestController < ActionController::Base
0
   end
0
   
0
   def embedded_actions
0
+ render :template => "test/embedded_actions"
0
   end
0
 
0
   def embedded_overrides
0
+ render :template => "test/embedded_overrides"
0
   end
0
 
0
   def forced_refresh
0
+ render :template => "test/forced_refresh"
0
   end
0
   
0
   def dump_params
...
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
...
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
0
@@ -98,4 +98,24 @@ class CachesEmbeddedTest < Test::Unit::TestCase
0
     get :forced_refresh
0
     assert_equal "regular value is 3\ncached value is 2", @response.body, "Another call without refresh should reflect the cached value"
0
   end
0
+
0
+ def test_caches_embedded_across_inheritance_tree
0
+ @controller = InheritingController.new
0
+
0
+ InheritingController.test_value = "foo"
0
+ get :inline_erb_action, :erb => "<%= embed_action :action => 'cached_action' %>"
0
+ assert_equal "foo", @response.body
0
+
0
+ InheritingController.test_value = "bar"
0
+ get :inline_erb_action, :erb => "<%= embed_action :action => 'cached_action' %>"
0
+ assert_equal "foo", @response.body
0
+
0
+ InheritingController.test_value = "bar"
0
+ @controller.expire_embedded :controller => "inheriting", :action => "cached_action"
0
+ get :inline_erb_action, :erb => "<%= embed_action :action => 'cached_action' %>"
0
+ assert_equal "bar", @response.body
0
+ end
0
+
0
+
0
 end
0
+

Comments

    No one has commented yet.