public
Description: rails plugin that enables inheritance of views along a controller class heirachy
Homepage: http://ianwhite.github.com/inherit_views
Clone URL: git://github.com/ianwhite/inherit_views.git
Make sure that ActionView::MissingTemplate is still raised when an inherited 
template can't be found
ianwhite (author)
Sun Sep 21 01:06:53 -0700 2008
commit  4f0e15b1099cc4e6b0729c7c5059fafceb58a1c7
tree    4f7a7aadd3527ca2a7094ea9320dddbf07dd0754
parent  e2d2e7e84ceb8da6d69bbea453f083c3d1dd4de0
...
9
10
11
 
 
12
13
14
...
52
53
54
55
 
56
57
 
...
9
10
11
12
13
14
15
16
...
54
55
56
 
57
58
 
59
0
@@ -9,6 +9,8 @@ AController < TestController; inherit_views (an instance)
0
 - GET :in_abc should render a/in_abc
0
 - GET :in_a should render a/in_a
0
 - GET :in_ab should render a/in_ab
0
+- GET :render_non_existent_partial should raise ActionView::TemplateError
0
+- GET :render_non_existent_template should raise ActionView::MissingTemplate
0
 
0
 BController < TestController; inherit_views 'a' (the class)
0
 - should be inherit views
0
@@ -52,6 +54,6 @@ DController < AController; inherit_views 'other' (an instance)
0
 NormalController
0
 - GET :partial_from_c should render normal/partial_from_c, then c/_partial_in_bc
0
 
0
-Finished in 0.348816 seconds
0
+Finished in 0.242443 seconds
0
 
0
-35 examples, 0 failures
0
+37 examples, 0 failures
...
44
45
46
47
48
49
50
51
52
53
...
103
104
105
106
 
107
108
 
 
109
 
110
111
112
...
124
125
126
 
127
128
129
...
44
45
46
 
 
 
 
47
48
49
...
99
100
101
 
102
103
 
104
105
106
107
108
109
110
...
122
123
124
125
126
127
128
0
@@ -44,10 +44,6 @@ module Ardes#:nodoc:
0
   #   end
0
   #
0
   module InheritViews
0
-    
0
-    # raised when an inherited file cannot be found, and one is required (e.g. in render_parent)
0
-    class InheritedFileNotFound < RuntimeError; end
0
-    
0
     # extension for ActionController::Base which enables inherit_views, this module is extended into
0
     # ActionController::Base
0
     module ActionController
0
@@ -103,10 +99,12 @@ module Ardes#:nodoc:
0
           
0
           def _pick_template(template_path)
0
             _orig_pick_template(template_path)
0
-          rescue ::ActionView::MissingTemplate
0
+          rescue ::ActionView::MissingTemplate => e
0
             if controller.respond_to?(:inherit_views?) && controller.inherit_views?
0
-              _pick_template_from_inherit_view_paths(template_path, controller.inherit_view_paths)
0
+              found = _pick_template_from_inherit_view_paths(template_path, controller.inherit_view_paths)
0
+              return found if found
0
             end
0
+            raise e
0
           end
0
           
0
           def _pick_template_from_inherit_view_paths(template_path, inherit_view_paths)
0
@@ -124,6 +122,7 @@ module Ardes#:nodoc:
0
                 return inherited_template if inherited_template
0
               end
0
             end
0
+            nil
0
           end
0
           memoize :_pick_template_from_inherit_view_paths
0
         end
...
6
7
8
 
 
 
 
9
10
11
...
23
24
25
26
 
27
28
...
6
7
8
9
10
11
12
13
14
15
...
27
28
29
 
30
31
32
0
@@ -6,6 +6,10 @@ end
0
 # its subclasses will inherit its views
0
 class AController < InheritViewsTestController
0
   inherit_views
0
+  
0
+  def render_non_existent_template
0
+    render :action => 'non_exitsent'
0
+  end
0
 end
0
 
0
 # :b controller is a normal controller with inherit_views 'a'
0
@@ -23,6 +27,6 @@ class DController < AController
0
   inherit_views 'other'
0
 end
0
 
0
-# used to test that inherit_views doesn't muck anything else up
0
+# used to test normal rails behaviour
0
 class NormalController < InheritViewsTestController
0
 end
...
33
34
35
 
 
 
 
 
 
 
 
36
37
38
...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
0
@@ -33,5 +33,13 @@ describe AController, " < TestController; inherit_views" do
0
       get :in_ab
0
       response.body.should == 'a:in_ab'
0
     end
0
+    
0
+    it "GET :render_non_existent_partial should raise ActionView::TemplateError" do
0
+      lambda { get :render_non_existent_partial }.should raise_error(ActionView::TemplateError)
0
+    end
0
+    
0
+    it "GET :render_non_existent_template should raise ActionView::MissingTemplate" do
0
+      lambda { get :render_non_existent_template }.should raise_error(ActionView::MissingTemplate)
0
+    end
0
   end
0
 end
0
\ No newline at end of file

Comments