actionpack 1.8.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (101) hide show
  1. data/CHANGELOG +309 -16
  2. data/README +1 -1
  3. data/lib/action_controller.rb +5 -0
  4. data/lib/action_controller/assertions.rb +57 -12
  5. data/lib/action_controller/auto_complete.rb +47 -0
  6. data/lib/action_controller/base.rb +288 -258
  7. data/lib/action_controller/benchmarking.rb +8 -3
  8. data/lib/action_controller/caching.rb +88 -42
  9. data/lib/action_controller/cgi_ext/cgi_ext.rb +1 -1
  10. data/lib/action_controller/cgi_ext/cgi_methods.rb +41 -11
  11. data/lib/action_controller/cgi_ext/multipart_progress.rb +169 -0
  12. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +30 -12
  13. data/lib/action_controller/cgi_process.rb +39 -11
  14. data/lib/action_controller/code_generation.rb +235 -0
  15. data/lib/action_controller/cookies.rb +14 -8
  16. data/lib/action_controller/deprecated_renders_and_redirects.rb +76 -0
  17. data/lib/action_controller/filters.rb +8 -7
  18. data/lib/action_controller/helpers.rb +41 -6
  19. data/lib/action_controller/layout.rb +45 -16
  20. data/lib/action_controller/request.rb +86 -23
  21. data/lib/action_controller/rescue.rb +1 -0
  22. data/lib/action_controller/response.rb +1 -1
  23. data/lib/action_controller/routing.rb +536 -272
  24. data/lib/action_controller/scaffolding.rb +30 -25
  25. data/lib/action_controller/session/active_record_store.rb +251 -50
  26. data/lib/action_controller/streaming.rb +133 -0
  27. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +0 -7
  28. data/lib/action_controller/templates/scaffolds/edit.rhtml +2 -2
  29. data/lib/action_controller/templates/scaffolds/layout.rhtml +22 -18
  30. data/lib/action_controller/templates/scaffolds/list.rhtml +3 -3
  31. data/lib/action_controller/templates/scaffolds/new.rhtml +2 -2
  32. data/lib/action_controller/templates/scaffolds/show.rhtml +1 -1
  33. data/lib/action_controller/test_process.rb +68 -47
  34. data/lib/action_controller/upload_progress.rb +421 -0
  35. data/lib/action_controller/url_rewriter.rb +8 -11
  36. data/lib/action_controller/vendor/html-scanner/html/document.rb +6 -5
  37. data/lib/action_controller/vendor/html-scanner/html/node.rb +70 -14
  38. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +17 -10
  39. data/lib/action_controller/vendor/html-scanner/html/version.rb +3 -3
  40. data/lib/action_controller/vendor/xml_simple.rb +1019 -0
  41. data/lib/action_controller/verification.rb +36 -30
  42. data/lib/action_view/base.rb +21 -14
  43. data/lib/action_view/helpers/active_record_helper.rb +15 -13
  44. data/lib/action_view/helpers/asset_tag_helper.rb +26 -9
  45. data/lib/action_view/helpers/benchmark_helper.rb +24 -0
  46. data/lib/action_view/helpers/capture_helper.rb +7 -5
  47. data/lib/action_view/helpers/date_helper.rb +63 -46
  48. data/lib/action_view/helpers/form_helper.rb +7 -1
  49. data/lib/action_view/helpers/form_options_helper.rb +19 -11
  50. data/lib/action_view/helpers/form_tag_helper.rb +5 -1
  51. data/lib/action_view/helpers/javascript_helper.rb +403 -35
  52. data/lib/action_view/helpers/javascripts/controls.js +261 -0
  53. data/lib/action_view/helpers/javascripts/dragdrop.js +476 -0
  54. data/lib/action_view/helpers/javascripts/effects.js +570 -0
  55. data/lib/action_view/helpers/javascripts/prototype.js +633 -371
  56. data/lib/action_view/helpers/number_helper.rb +11 -13
  57. data/lib/action_view/helpers/tag_helper.rb +1 -2
  58. data/lib/action_view/helpers/text_helper.rb +69 -6
  59. data/lib/action_view/helpers/upload_progress_helper.rb +433 -0
  60. data/lib/action_view/helpers/url_helper.rb +98 -3
  61. data/lib/action_view/partials.rb +14 -8
  62. data/lib/action_view/vendor/builder/xmlmarkup.rb +11 -0
  63. data/rakefile +13 -5
  64. data/test/abstract_unit.rb +1 -1
  65. data/test/controller/action_pack_assertions_test.rb +52 -9
  66. data/test/controller/active_record_assertions_test.rb +119 -120
  67. data/test/controller/active_record_store_test.rb +111 -0
  68. data/test/controller/addresses_render_test.rb +45 -0
  69. data/test/controller/caching_filestore.rb +92 -0
  70. data/test/controller/capture_test.rb +39 -0
  71. data/test/controller/cgi_test.rb +40 -3
  72. data/test/controller/helper_test.rb +65 -13
  73. data/test/controller/multipart_progress_testx.rb +365 -0
  74. data/test/controller/new_render_test.rb +263 -0
  75. data/test/controller/redirect_test.rb +64 -0
  76. data/test/controller/render_test.rb +20 -21
  77. data/test/controller/request_test.rb +83 -3
  78. data/test/controller/routing_test.rb +702 -0
  79. data/test/controller/send_file_test.rb +2 -0
  80. data/test/controller/test_test.rb +44 -8
  81. data/test/controller/upload_progress_testx.rb +89 -0
  82. data/test/controller/verification_test.rb +94 -29
  83. data/test/fixtures/addresses/list.rhtml +1 -0
  84. data/test/fixtures/test/capturing.rhtml +4 -0
  85. data/test/fixtures/test/list.rhtml +1 -1
  86. data/test/fixtures/test/update_element_with_capture.rhtml +9 -0
  87. data/test/template/active_record_helper_test.rb +30 -15
  88. data/test/template/asset_tag_helper_test.rb +12 -5
  89. data/test/template/benchmark_helper_test.rb +72 -0
  90. data/test/template/date_helper_test.rb +69 -0
  91. data/test/template/form_helper_test.rb +18 -10
  92. data/test/template/form_options_helper_test.rb +40 -5
  93. data/test/template/javascript_helper.rb +149 -2
  94. data/test/template/number_helper_test.rb +2 -0
  95. data/test/template/tag_helper_test.rb +4 -0
  96. data/test/template/text_helper_test.rb +36 -0
  97. data/test/template/upload_progress_helper_testx.rb +272 -0
  98. data/test/template/url_helper_test.rb +30 -0
  99. metadata +30 -6
  100. data/test/controller/layout_test.rb +0 -49
  101. data/test/controller/routing_tests.rb +0 -543
@@ -0,0 +1,365 @@
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
+ require 'logger'
3
+ require 'test/unit'
4
+ require 'cgi'
5
+ require 'stringio'
6
+
7
+ DEBUG=false
8
+
9
+ def test_logger
10
+ if DEBUG then ActionController::Base.logger = Logger.new(STDERR)
11
+ else ActionController::Base.logger = Logger.new(StringIO.new)
12
+ end
13
+ end
14
+
15
+ # Provide a static version of the Controllers module instead of the auto-loading version.
16
+ # We don't want these tests to fail when dependencies are to blame.
17
+ module Controllers
18
+ class EmptyController < ActionController::Base
19
+ end
20
+ class ApplicationController < ActionController::Base
21
+ end
22
+
23
+ class MockController < ActionController::Base
24
+ def initialize
25
+ super
26
+ @session = {:uploads => {}}
27
+ @params = {}
28
+ end
29
+ end
30
+
31
+ class SingleUploadController < ActionController::Base
32
+ upload_status_for :one
33
+
34
+ def one; end
35
+ end
36
+
37
+ class DoubleUploadController < ActionController::Base
38
+ upload_status_for :one, :two
39
+
40
+ def one; end
41
+ def two; end
42
+ end
43
+
44
+ class DoubleStatusUploadController < ActionController::Base
45
+ upload_status_for :one, :two, :status => :custom_status
46
+
47
+ def one; end
48
+ def two; end
49
+ end
50
+
51
+ class DoubleSeperateController < ActionController::Base
52
+ upload_status_for :one
53
+ upload_status_for :two
54
+
55
+ def one; end
56
+ def two; end
57
+ end
58
+
59
+ class UploadController < ActionController::Base
60
+ upload_status_for :norendered, :rendered, :redirected, :finish_param_dict, :finish_param_string, :finish_param_number
61
+
62
+ def norendered
63
+ end
64
+
65
+ def rendered
66
+ render_text("rendered")
67
+ end
68
+
69
+ def redirected
70
+ redirect_to "/redirected/"
71
+ end
72
+
73
+ def finish_param_dict
74
+ finish_upload_status "{a: 'b'}"
75
+ end
76
+
77
+ def finish_param_string
78
+ finish_upload_status "'a string'"
79
+ end
80
+
81
+ def finish_param_number
82
+ finish_upload_status 123
83
+ end
84
+
85
+ def finish_param_number_redirect
86
+ redirect_to "/redirected/"
87
+ finish_upload_status 123
88
+ end
89
+ end
90
+ end
91
+
92
+ class MockIO < StringIO
93
+ def initialize(data='', &block)
94
+ test_logger.debug("MockIO inializing data: #{data[0..20]}")
95
+
96
+ @block = block
97
+ super(data)
98
+ end
99
+
100
+ def write(data)
101
+ test_logger.debug("MockIO write #{data.size} data: #{data[0..20]}")
102
+ super
103
+ end
104
+ def read(size)
105
+ test_logger.debug("MockIO getting data from super")
106
+ data = super
107
+
108
+ test_logger.debug("Calling read callback")
109
+ @block.call
110
+
111
+ test_logger.debug("Returning data: #{data.size}")
112
+ data
113
+ end
114
+ end
115
+
116
+ class MockCGI < CGI
117
+ BOUNDARY = '----------0xKhTmLbOuNdArY'
118
+ FILENAME = 'dummy.nul'
119
+
120
+ attr_reader :upload_id, :session_options, :session_id
121
+
122
+ def initialize(size=1000, url='/test', &block)
123
+ @url = url
124
+ @env = {}
125
+ @sio = MockIO.new('') { block.call(self) if block_given? }
126
+
127
+ @upload_id = '1'
128
+
129
+ add_param('param1', 'value1')
130
+ add_data(size)
131
+ add_param('param1', 'value2')
132
+ add_end_boundary
133
+ init_env
134
+ @sio.rewind
135
+ super()
136
+ end
137
+
138
+ #def stdinput_without_progress
139
+ # @sio
140
+ #end
141
+
142
+ def stdinput
143
+ @sio
144
+ end
145
+
146
+ def env_table
147
+ @env
148
+ end
149
+
150
+ private
151
+ def init_env
152
+ @env['HTTP_HOST'] = 'localhost'
153
+ @env['SERVER_PORT'] = '80'
154
+ @env['REQUEST_METHOD'] = "POST"
155
+ @env['QUERY_STRING'] = @url.split('?')[1] || "upload_id=#{upload_id}&query_param=query_value"
156
+ @env['REQUEST_URI'] = @url
157
+ @env['SCRIPT_NAME'] = @url.split('?').first.split('/').last
158
+ @env['PATH_INFO'] = @url.split('?').first
159
+ @env['CONTENT_TYPE'] = "multipart/form-data; boundary=#{BOUNDARY}"
160
+ @env['CONTENT_LENGTH'] = @sio.tell - EOL.size
161
+
162
+ @session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.inject({}) { |options, pair|
163
+ options[pair.first.to_s] = pair.last; options
164
+ }
165
+ session = CGI::Session.new({}, @session_options.merge({'new_session' => true}))
166
+ @session_id = session.session_id
167
+ @env['COOKIE'] = "_session_id=#{session.session_id}"
168
+ session.close
169
+ end
170
+
171
+ def add_param(name, value)
172
+ add_boundary
173
+ @sio << "Content-Disposition: form-data; name=\"#{name}\"" << EOL << EOL
174
+ @sio << value.to_s << EOL
175
+ end
176
+
177
+ def add_data(size)
178
+ add_boundary
179
+ @sio << "Content-Disposition: form-data; name=\"file\"; filename=\"#{FILENAME}\"" << EOL
180
+ @sio << "Content-Type: application/octet-stream" << EOL << EOL
181
+ @sio << "." * size
182
+ @sio << EOL
183
+ end
184
+
185
+ def add_boundary
186
+ @sio << "--" << BOUNDARY << EOL
187
+ end
188
+
189
+ def add_end_boundary
190
+ @sio << "--" << BOUNDARY << "--" << EOL
191
+ end
192
+ end
193
+
194
+ class MultipartProgressTest < Test::Unit::TestCase
195
+
196
+ def test_domain_language_single
197
+ c = Controllers::SingleUploadController.new
198
+ assert_respond_to(c, :one)
199
+ assert_respond_to(c, :upload_status)
200
+ assert_respond_to(c, :finish_upload_status)
201
+ end
202
+
203
+ def test_domain_language_double
204
+ c = Controllers::DoubleUploadController.new
205
+ assert_respond_to(c, :one)
206
+ assert_respond_to(c, :two)
207
+ assert_respond_to(c, :upload_status)
208
+ assert_respond_to(c, :finish_upload_status)
209
+ end
210
+
211
+ def test_domain_language_double_status
212
+ c = Controllers::DoubleStatusUploadController.new
213
+ assert_respond_to(c, :one)
214
+ assert_respond_to(c, :two)
215
+ assert_respond_to(c, :custom_status)
216
+ assert_respond_to(c, :finish_upload_status)
217
+ end
218
+
219
+ def test_domain_language_double_seperate
220
+ c = Controllers::DoubleSeperateController.new
221
+ assert_respond_to(c, :one)
222
+ assert_respond_to(c, :two)
223
+ assert_respond_to(c, :upload_status)
224
+ assert_respond_to(c, :finish_upload_status)
225
+ end
226
+
227
+ def test_finish_status_norendered
228
+ # Fails to render the upload finish script because there is no view associated with this action
229
+ test_logger.debug('test_finish_status_norendered')
230
+
231
+ res = process(:action => 'norendered', :upload_id => 1)
232
+ assert_match(/ActionView::ActionViewError/s, res.body)
233
+
234
+ res = process(:action => :upload_status, :upload_id => 1)
235
+ assert_match(/Upload finished/s, res.body)
236
+
237
+ res = process(:action => :norendered)
238
+ assert_match(/ActionView::ActionViewError/s, res.body)
239
+ end
240
+
241
+ def test_finish_status_rendered
242
+ test_logger.debug('test_finish_status_rendered')
243
+
244
+ res = process(:action => :rendered, :upload_id => 1)
245
+ assert_match(/stop\(\)/s, res.body)
246
+ assert_no_match(/rendered/s, res.body)
247
+
248
+ res = process(:action => :upload_status, :upload_id => 1)
249
+ assert_match(/Upload finished/s, res.body)
250
+
251
+ res = process(:action => :rendered)
252
+ assert_no_match(/stop\(\)/s, res.body)
253
+ assert_match(/rendered/, res.body)
254
+ end
255
+
256
+ def test_finish_status_redirected
257
+ test_logger.debug('test_finish_status_redirected')
258
+
259
+ res = process(:action => :redirected, :upload_id => 1)
260
+ assert_match(/location\.replace/s, res.body)
261
+
262
+ res = process(:action => :redirected)
263
+ assert_no_match(/location\.replace/s, res.body)
264
+ assert_match(/\/redirected\//s, res.headers['location'])
265
+ assert_match(/302 .*$/, res.headers['Status'])
266
+
267
+ res = process(:action => :upload_status, :upload_id => 1)
268
+ assert_match(/Upload finished/s, res.body)
269
+ end
270
+
271
+ def test_finish_status_finish_param
272
+ test_logger.debug('test_finish_status_param')
273
+
274
+ res = process(:action => :finish_param_string, :upload_id => 1)
275
+ assert_match(/stop\('a string'\)/s, res.body)
276
+ assert_no_redirect res
277
+
278
+ res = process(:action => :finish_param_dict, :upload_id => 1)
279
+ assert_match(/stop\(\{a: 'b'\}\)/s, res.body)
280
+ assert_no_redirect res
281
+
282
+ res = process(:action => :finish_param_number, :upload_id => 1)
283
+ assert_match(/stop\(123\)/s, res.body)
284
+ assert_no_redirect res
285
+
286
+ res = process(:action => :finish_param_number_redirect, :upload_id => 1)
287
+ test_logger.debug('test_finish_status_param: ' + res.body)
288
+ assert_match(/stop\(123\)/s, res.body)
289
+ assert_match(/replace\('\http:\/\/localhost\/redirected\/'\).*?/s, res.body)
290
+ assert_no_redirect res
291
+ end
292
+
293
+ def test_basic_setup
294
+ test_logger.debug('test_basic_setup')
295
+
296
+ cgi, request, response = new_request(100000)
297
+ assert_not_nil(request.session)
298
+ assert_not_nil(request.session[:uploads], "uploads collection not set")
299
+ assert_not_nil(request.session[:uploads][cgi.upload_id], "upload id not set")
300
+ progress = request.session[:uploads][cgi.upload_id]
301
+ assert_equal(true, progress.finished?)
302
+ end
303
+
304
+ def test_params
305
+ test_logger.debug('test_params')
306
+
307
+ cgi, request, response = new_request(1000)
308
+ assert(!request.params.empty?)
309
+ assert(!request.params['param1'].empty?)
310
+ end
311
+
312
+ def test_share_session
313
+ cgi, request, response = new_request(100000) do |cgi, req|
314
+ if cgi.stdinput.tell > 50000
315
+ # force a save
316
+ cgi.stdinput.save_progress rescue flunk('Something else is wrong, our wrapper isnt setup, is ActionController::Base.logger set?')
317
+
318
+ other_session = CGI::Session.new(cgi, cgi.session_options.merge({'session_id' => cgi.session_id}))
319
+ assert_not_nil(other_session[:uploads])
320
+ assert_not_nil(other_session[:uploads][cgi.upload_id])
321
+ assert_in_delta(cgi.stdinput.session[:uploads][cgi.upload_id].bitrate, other_session[:uploads][cgi.upload_id].bitrate, 1000.0, "Seperate session does not share data from original session")
322
+
323
+ other_session.close
324
+ end
325
+ end
326
+ end
327
+
328
+ def test_upload_ids
329
+ c = Controllers::MockController.new
330
+ (1..222).each do |id|
331
+ c.params = {}
332
+
333
+ assert_equal((id-1).to_s, c.last_upload_id, "last_upload_id is out of sync")
334
+ assert_equal(id.to_s, c.next_upload_id, "next_upload_id is out of sync")
335
+ assert_equal(id.to_s, c.current_upload_id, "current_upload_id is out of sync")
336
+
337
+ c.params = {:upload_id => (id-1).to_s}
338
+ assert_equal((id-1).to_s, c.current_upload_id, "current_upload_id is out of sync")
339
+
340
+ c.session[:uploads][id] = {}
341
+ end
342
+ end
343
+
344
+ private
345
+ def new_request(size=1000, url='/test', &block)
346
+ test_logger.debug('Creating MockCGI')
347
+ cgi = MockCGI.new(size, url) do |cgi|
348
+ block.call(cgi) if block_given?
349
+ end
350
+
351
+ assert(cgi.private_methods.include?("read_multipart_with_progress"))
352
+ return [cgi, ActionController::CgiRequest.new(cgi), ActionController::CgiResponse.new(cgi)]
353
+ end
354
+
355
+ def process(options = {})
356
+ Controllers::UploadController.process(*(new_request(1000, '/upload?' + options.map {|k,v| "#{k}=#{v}"}.join('&'))[1..2]))
357
+ end
358
+
359
+ def assert_no_redirect(res)
360
+ assert_nil(res.redirected_to)
361
+ assert_nil(res.headers['location'])
362
+ assert_match(/200 .*$/, res.headers['Status'])
363
+ end
364
+
365
+ end
@@ -0,0 +1,263 @@
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
+
3
+ silence_warnings { Customer = Struct.new("Customer", :name) }
4
+
5
+ module Fun
6
+ class GamesController < ActionController::Base
7
+ def hello_world
8
+ end
9
+ end
10
+ end
11
+
12
+ class NewRenderTestController < ActionController::Base
13
+ layout :determine_layout
14
+
15
+ def self.controller_name; "test"; end
16
+ def self.controller_path; "test"; end
17
+
18
+ def hello_world
19
+ end
20
+
21
+ def render_hello_world
22
+ render :template => "test/hello_world"
23
+ end
24
+
25
+ def render_hello_world_from_variable
26
+ @person = "david"
27
+ render :text => "hello #{@person}"
28
+ end
29
+
30
+ def render_action_hello_world
31
+ render :action => "hello_world"
32
+ end
33
+
34
+ def render_text_hello_world
35
+ render :text => "hello world"
36
+ end
37
+
38
+ def render_custom_code
39
+ render :text => "hello world", :status => "404 Moved"
40
+ end
41
+
42
+ def render_xml_hello
43
+ @name = "David"
44
+ render :template => "test/hello"
45
+ end
46
+
47
+ def greeting
48
+ # let's just rely on the template
49
+ end
50
+
51
+ def layout_test
52
+ render :action => "hello_world"
53
+ end
54
+
55
+ def layout_test_with_different_layout
56
+ render :action => "hello_world", :layout => "standard"
57
+ end
58
+
59
+ def rendering_without_layout
60
+ render :action => "hello_world", :layout => false
61
+ end
62
+
63
+ def rendering_nothing_on_layout
64
+ render :nothing => true
65
+ end
66
+
67
+ def builder_layout_test
68
+ render :action => "hello"
69
+ end
70
+
71
+ def partials_list
72
+ @test_unchanged = 'hello'
73
+ @customers = [ Customer.new("david"), Customer.new("mary") ]
74
+ render :action => "list"
75
+ end
76
+
77
+ def partial_only
78
+ render :partial => true
79
+ end
80
+
81
+ def partial_only_with_layout
82
+ render :partial => "partial_only", :layout => true
83
+ end
84
+
85
+ def hello_in_a_string
86
+ @customers = [ Customer.new("david"), Customer.new("mary") ]
87
+ render :text => "How's there? #{render_to_string("test/list")}"
88
+ end
89
+
90
+ def accessing_params_in_template
91
+ render :inline => "Hello: <%= params[:name] %>"
92
+ end
93
+
94
+ def accessing_params_in_template_with_layout
95
+ render :inline => "Hello: <%= params[:name] %>", :layout => nil
96
+ end
97
+
98
+ def render_with_explicit_template
99
+ render "test/hello_world"
100
+ end
101
+
102
+ def rescue_action(e) raise end
103
+
104
+ private
105
+ def determine_layout
106
+ case action_name
107
+ when "hello_world", "layout_test", "rendering_without_layout",
108
+ "rendering_nothing_on_layout", "render_text_hello_world",
109
+ "partial_only", "partial_only_with_layout",
110
+ "accessing_params_in_template",
111
+ "accessing_params_in_template_with_layout",
112
+ "render_with_explicit_template"
113
+ "layouts/standard"
114
+ when "builder_layout_test"
115
+ "layouts/builder"
116
+ end
117
+ end
118
+ end
119
+
120
+ NewRenderTestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
121
+ Fun::GamesController.template_root = File.dirname(__FILE__) + "/../fixtures/"
122
+
123
+ class NewRenderTest < Test::Unit::TestCase
124
+ def setup
125
+ @controller = NewRenderTestController.new
126
+
127
+ # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
128
+ # a more accurate simulation of what happens in "real life".
129
+ @controller.logger = Logger.new(nil)
130
+
131
+ @request = ActionController::TestRequest.new
132
+ @response = ActionController::TestResponse.new
133
+
134
+ @request.host = "www.nextangle.com"
135
+ end
136
+
137
+ def test_simple_show
138
+ get :hello_world
139
+ assert_response :success
140
+ assert_template "test/hello_world"
141
+ assert_equal "<html>Hello world!</html>", @response.body
142
+ end
143
+
144
+ def test_do_with_render
145
+ get :render_hello_world
146
+ assert_template "test/hello_world"
147
+ end
148
+
149
+ def test_do_with_render_from_variable
150
+ get :render_hello_world_from_variable
151
+ assert_equal "hello david", @response.body
152
+ end
153
+
154
+ def test_do_with_render_action
155
+ get :render_action_hello_world
156
+ assert_template "test/hello_world"
157
+ end
158
+
159
+ def test_do_with_render_text
160
+ get :render_text_hello_world
161
+ assert_equal "hello world", @response.body
162
+ end
163
+
164
+ def test_do_with_render_custom_code
165
+ get :render_custom_code
166
+ assert_response :missing
167
+ end
168
+
169
+ def test_attempt_to_access_object_method
170
+ assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
171
+ end
172
+
173
+ def test_private_methods
174
+ assert_raises(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
175
+ end
176
+
177
+ def test_access_to_request_in_view
178
+ ActionController::Base.view_controller_internals = false
179
+
180
+ get :hello_world
181
+ assert_nil(assigns["request"])
182
+
183
+ ActionController::Base.view_controller_internals = true
184
+
185
+ get :hello_world
186
+ assert_kind_of ActionController::AbstractRequest, assigns["request"]
187
+ end
188
+
189
+ def test_render_xml
190
+ get :render_xml_hello
191
+ assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
192
+ end
193
+
194
+ def test_render_xml_with_default
195
+ get :greeting
196
+ assert_equal "<p>This is grand!</p>\n", @response.body
197
+ end
198
+
199
+ def test_layout_rendering
200
+ get :layout_test
201
+ assert_equal "<html>Hello world!</html>", @response.body
202
+ end
203
+
204
+ def test_layout_test_with_different_layout
205
+ get :layout_test_with_different_layout
206
+ assert_equal "<html>Hello world!</html>", @response.body
207
+ end
208
+
209
+ def test_rendering_without_layout
210
+ get :rendering_without_layout
211
+ assert_equal "Hello world!", @response.body
212
+ end
213
+
214
+ def test_rendering_nothing_on_layout
215
+ get :rendering_nothing_on_layout
216
+ assert_equal "", @response.body
217
+ end
218
+
219
+ def test_render_xml_with_layouts
220
+ get :builder_layout_test
221
+ assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
222
+ end
223
+
224
+ # def test_partials_list
225
+ # get :partials_list
226
+ # assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body
227
+ # end
228
+
229
+ def test_partial_only
230
+ get :partial_only
231
+ assert_equal "only partial", @response.body
232
+ end
233
+
234
+ def test_partial_only_with_layout
235
+ get :partial_only_with_layout
236
+ assert_equal "<html>only partial</html>", @response.body
237
+ end
238
+
239
+ def test_render_to_string
240
+ get :hello_in_a_string
241
+ assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body
242
+ end
243
+
244
+ def test_nested_rendering
245
+ get :hello_world
246
+ assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body
247
+ end
248
+
249
+ def test_accessing_params_in_template
250
+ get :accessing_params_in_template, :name => "David"
251
+ assert_equal "Hello: David", @response.body
252
+ end
253
+
254
+ def test_accessing_params_in_template_with_layout
255
+ get :accessing_params_in_template_with_layout, :name => "David"
256
+ assert_equal "<html>Hello: David</html>", @response.body
257
+ end
258
+
259
+ def test_render_with_explicit_template
260
+ get :render_with_explicit_template
261
+ assert_response :success
262
+ end
263
+ end