Skip to content
This repository
Browse code

Whitespace

  • Loading branch information...
commit 485512c50f889adda2597fa1d3f3d5b47870617d 1 parent 209fb51
Yehuda Katz authored April 04, 2010
67  actionpack/test/abstract/abstract_controller_test.rb
@@ -2,21 +2,21 @@
2 2
 
3 3
 module AbstractController
4 4
   module Testing
5  
-  
  5
+
6 6
     # Test basic dispatching.
7 7
     # ====
8 8
     # * Call process
9 9
     # * Test that the response_body is set correctly
10 10
     class SimpleController < AbstractController::Base
11 11
     end
12  
-    
  12
+
13 13
     class Me < SimpleController
14 14
       def index
15 15
         self.response_body = "Hello world"
16 16
         "Something else"
17  
-      end      
  17
+      end
18 18
     end
19  
-    
  19
+
20 20
     class TestBasic < ActiveSupport::TestCase
21 21
       test "dispatching works" do
22 22
         controller = Me.new
@@ -24,7 +24,7 @@ class TestBasic < ActiveSupport::TestCase
24 24
         assert_equal "Hello world", controller.response_body
25 25
       end
26 26
     end
27  
-    
  27
+
28 28
     # Test Render mixin
29 29
     # ====
30 30
     class RenderingController < AbstractController::Base
@@ -36,19 +36,18 @@ def render(options = {})
36 36
         if options.is_a?(String)
37 37
           options = {:_template_name => options}
38 38
         end
39  
-        
  39
+
40 40
         options[:_prefix] = _prefix
41 41
         super
42 42
       end
43 43
 
44 44
       append_view_path File.expand_path(File.join(File.dirname(__FILE__), "views"))
45 45
     end
46  
-    
  46
+
47 47
     class Me2 < RenderingController
48 48
       def index
49 49
         render "index.erb"
50 50
       end
51  
-      
52 51
 
53 52
       def index_to_string
54 53
         self.response_body = render_to_string "index.erb"
@@ -58,7 +57,7 @@ def action_with_ivars
58 57
         @my_ivar = "Hello"
59 58
         render "action_with_ivars.erb"
60 59
       end
61  
-      
  60
+
62 61
       def naked_render
63 62
         render
64 63
       end
@@ -81,7 +80,7 @@ def setup
81 80
         @controller.process(:index)
82 81
         assert_equal "Hello from index.erb", @controller.response_body
83 82
       end
84  
-      
  83
+
85 84
       test "render_to_string works with a String as an argument" do
86 85
         @controller.process(:index_to_string)
87 86
         assert_equal "Hello from index.erb", @controller.response_body
@@ -91,7 +90,7 @@ def setup
91 90
         @controller.process(:action_with_ivars)
92 91
         assert_equal "Hello from index_with_ivars.erb", @controller.response_body
93 92
       end
94  
-      
  93
+
95 94
       test "rendering with no template name" do
96 95
         @controller.process(:naked_render)
97 96
         assert_equal "Hello from naked_render.erb", @controller.response_body
@@ -107,7 +106,7 @@ def setup
107 106
         assert_equal "Hello from naked_render.erb", @controller.response_body
108 107
       end
109 108
     end
110  
-    
  109
+
111 110
     # Test rendering with prefixes
112 111
     # ====
113 112
     # * self._prefix is used when defined
@@ -116,23 +115,23 @@ class PrefixedViews < RenderingController
116 115
       def self.prefix
117 116
         name.underscore
118 117
       end
119  
-      
  118
+
120 119
       def _prefix
121 120
         self.class.prefix
122 121
       end
123 122
     end
124  
-    
  123
+
125 124
     class Me3 < PrefixedViews
126 125
       def index
127 126
         render
128 127
       end
129  
-      
  128
+
130 129
       def formatted
131 130
         self.formats = [:html]
132 131
         render
133 132
       end
134 133
     end
135  
-    
  134
+
136 135
     class TestPrefixedViews < ActiveSupport::TestCase
137 136
       def setup
138 137
         @controller = Me3.new
@@ -148,13 +147,13 @@ def setup
148 147
         assert_equal "Hello from me3/formatted.html.erb", @controller.response_body
149 148
       end
150 149
     end
151  
-    
  150
+
152 151
     # Test rendering with layouts
153 152
     # ====
154 153
     # self._layout is used when defined
155 154
     class WithLayouts < PrefixedViews
156 155
       include Layouts
157  
-      
  156
+
158 157
       private
159 158
       def self.layout(formats)
160 159
         begin
@@ -170,21 +169,21 @@ def self.layout(formats)
170 169
       def render_to_body(options = {})
171 170
         options[:_layout] = options[:layout] || _default_layout({})
172 171
         super
173  
-      end  
  172
+      end
174 173
     end
175  
-    
  174
+
176 175
     class Me4 < WithLayouts
177 176
       def index
178 177
         render
179 178
       end
180 179
     end
181  
-    
  180
+
182 181
     class Me5 < WithLayouts
183 182
       def index
184 183
         render
185 184
       end
186 185
     end
187  
-    
  186
+
188 187
     class TestLayouts < ActiveSupport::TestCase
189 188
       test "layouts are included" do
190 189
         controller = Me4.new
@@ -192,7 +191,7 @@ class TestLayouts < ActiveSupport::TestCase
192 191
         assert_equal "Me4 Enter : Hello from me4/index.erb : Exit", controller.response_body
193 192
       end
194 193
     end
195  
-    
  194
+
196 195
     # respond_to_action?(action_name)
197 196
     # ====
198 197
     # * A method can be used as an action only if this method
@@ -201,7 +200,7 @@ class TestLayouts < ActiveSupport::TestCase
201 200
     class DefaultRespondToActionController < AbstractController::Base
202 201
       def index() self.response_body = "success" end
203 202
     end
204  
-    
  203
+
205 204
     class ActionMissingRespondToActionController < AbstractController::Base
206 205
       # No actions
207 206
     private
@@ -209,19 +208,19 @@ def action_missing(action_name)
209 208
         self.response_body = "success"
210 209
       end
211 210
     end
212  
-    
  211
+
213 212
     class RespondToActionController < AbstractController::Base;
214 213
       def index() self.response_body = "success" end
215  
-        
  214
+
216 215
       def fail()  self.response_body = "fail"    end
217  
-        
  216
+
218 217
     private
219 218
 
220 219
       def method_for_action(action_name)
221 220
         action_name.to_s != "fail" && action_name
222 221
       end
223 222
     end
224  
-    
  223
+
225 224
     class TestRespondToAction < ActiveSupport::TestCase
226 225
 
227 226
       def assert_dispatch(klass, body = "success", action = :index)
@@ -229,27 +228,27 @@ def assert_dispatch(klass, body = "success", action = :index)
229 228
         controller.process(action)
230 229
         assert_equal body, controller.response_body
231 230
       end
232  
-      
  231
+
233 232
       test "an arbitrary method is available as an action by default" do
234 233
         assert_dispatch DefaultRespondToActionController, "success", :index
235 234
       end
236  
-      
  235
+
237 236
       test "raises ActionNotFound when method does not exist and action_missing is not defined" do
238 237
         assert_raise(ActionNotFound) { DefaultRespondToActionController.new.process(:fail) }
239 238
       end
240  
-      
  239
+
241 240
       test "dispatches to action_missing when method does not exist and action_missing is defined" do
242 241
         assert_dispatch ActionMissingRespondToActionController, "success", :ohai
243 242
       end
244  
-      
  243
+
245 244
       test "a method is available as an action if respond_to_action? returns true" do
246 245
         assert_dispatch RespondToActionController, "success", :index
247 246
       end
248  
-      
  247
+
249 248
       test "raises ActionNotFound if method is defined but respond_to_action? returns false" do
250 249
         assert_raise(ActionNotFound) { RespondToActionController.new.process(:fail) }
251 250
       end
252 251
     end
253  
-    
  252
+
254 253
   end
255 254
 end

0 notes on commit 485512c

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