actionpack 1.11.2 → 1.12.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 (149) hide show
  1. data/CHANGELOG +392 -5
  2. data/lib/action_controller.rb +8 -4
  3. data/lib/action_controller/assertions.rb +9 -10
  4. data/lib/action_controller/base.rb +177 -88
  5. data/lib/action_controller/benchmarking.rb +5 -5
  6. data/lib/action_controller/caching.rb +44 -36
  7. data/lib/action_controller/cgi_ext/cgi_methods.rb +71 -6
  8. data/lib/action_controller/cgi_ext/cookie_performance_fix.rb +1 -1
  9. data/lib/action_controller/cgi_process.rb +36 -24
  10. data/lib/action_controller/components.rb +152 -52
  11. data/lib/action_controller/dependencies.rb +1 -1
  12. data/lib/action_controller/deprecated_redirects.rb +2 -2
  13. data/lib/action_controller/deprecated_request_methods.rb +34 -0
  14. data/lib/action_controller/filters.rb +59 -19
  15. data/lib/action_controller/flash.rb +53 -47
  16. data/lib/action_controller/helpers.rb +2 -2
  17. data/lib/action_controller/integration.rb +524 -0
  18. data/lib/action_controller/layout.rb +58 -23
  19. data/lib/action_controller/mime_responds.rb +163 -0
  20. data/lib/action_controller/mime_type.rb +142 -0
  21. data/lib/action_controller/pagination.rb +13 -7
  22. data/lib/action_controller/request.rb +59 -56
  23. data/lib/action_controller/rescue.rb +1 -1
  24. data/lib/action_controller/routing.rb +29 -10
  25. data/lib/action_controller/scaffolding.rb +8 -0
  26. data/lib/action_controller/session/active_record_store.rb +21 -10
  27. data/lib/action_controller/session/mem_cache_store.rb +18 -12
  28. data/lib/action_controller/session_management.rb +30 -11
  29. data/lib/action_controller/templates/rescues/_trace.rhtml +1 -1
  30. data/lib/action_controller/templates/scaffolds/layout.rhtml +4 -4
  31. data/lib/action_controller/templates/scaffolds/list.rhtml +1 -1
  32. data/lib/action_controller/test_process.rb +189 -118
  33. data/lib/action_controller/vendor/html-scanner/html/node.rb +20 -1
  34. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +3 -0
  35. data/lib/action_controller/vendor/html-scanner/html/version.rb +1 -1
  36. data/lib/action_controller/vendor/xml_node.rb +97 -0
  37. data/lib/action_controller/verification.rb +2 -0
  38. data/lib/action_pack/version.rb +3 -3
  39. data/lib/action_view.rb +0 -2
  40. data/lib/action_view/base.rb +109 -36
  41. data/lib/action_view/compiled_templates.rb +1 -1
  42. data/lib/action_view/helpers/active_record_helper.rb +4 -2
  43. data/lib/action_view/helpers/asset_tag_helper.rb +6 -7
  44. data/lib/action_view/helpers/capture_helper.rb +49 -12
  45. data/lib/action_view/helpers/date_helper.rb +14 -4
  46. data/lib/action_view/helpers/form_helper.rb +136 -20
  47. data/lib/action_view/helpers/form_options_helper.rb +29 -7
  48. data/lib/action_view/helpers/form_tag_helper.rb +22 -20
  49. data/lib/action_view/helpers/java_script_macros_helper.rb +29 -9
  50. data/lib/action_view/helpers/javascript_helper.rb +50 -446
  51. data/lib/action_view/helpers/javascripts/controls.js +95 -30
  52. data/lib/action_view/helpers/javascripts/dragdrop.js +161 -21
  53. data/lib/action_view/helpers/javascripts/effects.js +310 -211
  54. data/lib/action_view/helpers/javascripts/prototype.js +228 -28
  55. data/lib/action_view/helpers/number_helper.rb +9 -9
  56. data/lib/action_view/helpers/pagination_helper.rb +1 -1
  57. data/lib/action_view/helpers/prototype_helper.rb +900 -0
  58. data/lib/action_view/helpers/scriptaculous_helper.rb +135 -0
  59. data/lib/action_view/helpers/text_helper.rb +7 -6
  60. data/lib/action_view/helpers/url_helper.rb +23 -14
  61. data/lib/action_view/partials.rb +12 -4
  62. data/rakefile +13 -5
  63. data/test/abstract_unit.rb +4 -3
  64. data/test/active_record_unit.rb +88 -0
  65. data/test/{controller → activerecord}/active_record_assertions_test.rb +7 -50
  66. data/test/{controller → activerecord}/active_record_store_test.rb +27 -4
  67. data/test/activerecord/pagination_test.rb +161 -0
  68. data/test/controller/action_pack_assertions_test.rb +18 -15
  69. data/test/controller/base_test.rb +31 -42
  70. data/test/controller/benchmark_test.rb +8 -11
  71. data/test/controller/capture_test.rb +33 -1
  72. data/test/controller/cgi_test.rb +33 -0
  73. data/test/controller/custom_handler_test.rb +8 -0
  74. data/test/controller/fake_controllers.rb +9 -17
  75. data/test/controller/filters_test.rb +32 -3
  76. data/test/controller/flash_test.rb +26 -41
  77. data/test/controller/fragment_store_setting_test.rb +1 -1
  78. data/test/controller/layout_test.rb +73 -0
  79. data/test/controller/mime_responds_test.rb +257 -0
  80. data/test/controller/mime_type_test.rb +24 -0
  81. data/test/controller/new_render_test.rb +157 -1
  82. data/test/controller/redirect_test.rb +23 -0
  83. data/test/controller/render_test.rb +54 -56
  84. data/test/controller/request_test.rb +25 -0
  85. data/test/controller/routing_test.rb +74 -66
  86. data/test/controller/test_test.rb +66 -1
  87. data/test/controller/verification_test.rb +3 -1
  88. data/test/controller/webservice_test.rb +255 -0
  89. data/test/fixtures/companies.yml +24 -0
  90. data/test/fixtures/company.rb +9 -0
  91. data/test/fixtures/db_definitions/sqlite.sql +42 -0
  92. data/test/fixtures/developer.rb +7 -0
  93. data/test/fixtures/developers.yml +21 -0
  94. data/test/fixtures/developers_projects.yml +13 -0
  95. data/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
  96. data/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
  97. data/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
  98. data/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
  99. data/test/fixtures/layout_tests/views/hello.rhtml +1 -0
  100. data/test/fixtures/multipart/mona_lisa.jpg +0 -0
  101. data/test/fixtures/project.rb +3 -0
  102. data/test/fixtures/projects.yml +7 -0
  103. data/test/fixtures/replies.yml +13 -0
  104. data/test/fixtures/reply.rb +5 -0
  105. data/test/fixtures/respond_to/all_types_with_layout.rhtml +1 -0
  106. data/test/fixtures/respond_to/all_types_with_layout.rjs +1 -0
  107. data/test/fixtures/respond_to/layouts/standard.rhtml +1 -0
  108. data/test/fixtures/respond_to/using_defaults.rhtml +1 -0
  109. data/test/fixtures/respond_to/using_defaults.rjs +1 -0
  110. data/test/fixtures/respond_to/using_defaults.rxml +1 -0
  111. data/test/fixtures/respond_to/using_defaults_with_type_list.rhtml +1 -0
  112. data/test/fixtures/respond_to/using_defaults_with_type_list.rjs +1 -0
  113. data/test/fixtures/respond_to/using_defaults_with_type_list.rxml +1 -0
  114. data/test/fixtures/test/block_content_for.rhtml +2 -0
  115. data/test/fixtures/test/delete_with_js.rjs +2 -0
  116. data/test/fixtures/test/dot.directory/render_file_with_ivar.rhtml +1 -0
  117. data/test/fixtures/test/enum_rjs_test.rjs +6 -0
  118. data/test/fixtures/test/erb_content_for.rhtml +2 -0
  119. data/test/fixtures/test/hello_world.rxml +3 -0
  120. data/test/fixtures/test/hello_world_with_layout_false.rhtml +1 -0
  121. data/test/fixtures/test/non_erb_block_content_for.rxml +4 -0
  122. data/test/fixtures/topic.rb +3 -0
  123. data/test/fixtures/topics.yml +22 -0
  124. data/test/template/active_record_helper_test.rb +4 -0
  125. data/test/template/asset_tag_helper_test.rb +7 -2
  126. data/test/template/date_helper_test.rb +39 -2
  127. data/test/template/form_helper_test.rb +238 -5
  128. data/test/template/form_options_helper_test.rb +78 -0
  129. data/test/template/form_tag_helper_test.rb +11 -0
  130. data/test/template/java_script_macros_helper_test.rb +51 -6
  131. data/test/template/javascript_helper_test.rb +7 -153
  132. data/test/template/number_helper_test.rb +14 -13
  133. data/test/template/prototype_helper_test.rb +423 -0
  134. data/test/template/scriptaculous_helper_test.rb +90 -0
  135. data/test/template/text_helper_test.rb +12 -9
  136. data/test/template/url_helper_test.rb +31 -15
  137. metadata +291 -246
  138. data/lib/action_controller/cgi_ext/multipart_progress.rb +0 -169
  139. data/lib/action_controller/upload_progress.rb +0 -473
  140. data/lib/action_controller/vendor/html-scanner/html/node.rb.rej +0 -17
  141. data/lib/action_view/helpers/upload_progress_helper.rb +0 -433
  142. data/lib/action_view/vendor/builder.rb +0 -13
  143. data/lib/action_view/vendor/builder/blankslate.rb +0 -53
  144. data/lib/action_view/vendor/builder/xmlbase.rb +0 -143
  145. data/lib/action_view/vendor/builder/xmlevents.rb +0 -63
  146. data/lib/action_view/vendor/builder/xmlmarkup.rb +0 -308
  147. data/test/controller/multipart_progress_testx.rb +0 -365
  148. data/test/controller/upload_progress_testx.rb +0 -89
  149. data/test/template/upload_progress_helper_testx.rb +0 -136
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
+
3
+ class MimeTypeTest < Test::Unit::TestCase
4
+ Mime::PNG = Mime::Type.new("image/png")
5
+ Mime::PLAIN = Mime::Type.new("text/plain")
6
+
7
+ def test_parse_single
8
+ Mime::LOOKUP.keys.each do |mime_type|
9
+ assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type)
10
+ end
11
+ end
12
+
13
+ def test_parse_without_q
14
+ accept = "text/xml,application/xhtml+xml,text/yaml,application/xml,text/html,image/png,text/plain,*/*"
15
+ expect = [Mime::HTML, Mime::XML, Mime::YAML, Mime::PNG, Mime::PLAIN, Mime::ALL]
16
+ assert_equal expect, Mime::Type.parse(accept)
17
+ end
18
+
19
+ def test_parse_with_q
20
+ accept = "text/xml,application/xhtml+xml,text/yaml; q=0.3,application/xml,text/html; q=0.8,image/png,text/plain; q=0.5,*/*; q=0.2"
21
+ expect = [Mime::HTML, Mime::XML, Mime::PNG, Mime::PLAIN, Mime::YAML, Mime::ALL]
22
+ assert_equal expect, Mime::Type.parse(accept)
23
+ end
24
+ end
@@ -9,6 +9,12 @@ module Fun
9
9
  end
10
10
  end
11
11
 
12
+ module NewRenderTestHelper
13
+ def rjs_helper_method_from_module
14
+ page.visual_effect :highlight
15
+ end
16
+ end
17
+
12
18
  class NewRenderTestController < ActionController::Base
13
19
  layout :determine_layout
14
20
 
@@ -30,6 +36,10 @@ class NewRenderTestController < ActionController::Base
30
36
  def render_action_hello_world
31
37
  render :action => "hello_world"
32
38
  end
39
+
40
+ def render_action_hello_world_as_symbol
41
+ render :action => :hello_world
42
+ end
33
43
 
34
44
  def render_text_hello_world
35
45
  render :text => "hello world"
@@ -40,6 +50,10 @@ class NewRenderTestController < ActionController::Base
40
50
  render :text => "hello world", :layout => true
41
51
  end
42
52
 
53
+ def hello_world_with_layout_false
54
+ render :layout => false
55
+ end
56
+
43
57
  def render_custom_code
44
58
  render :text => "hello world", :status => "404 Moved"
45
59
  end
@@ -59,7 +73,17 @@ class NewRenderTestController < ActionController::Base
59
73
  @secret = 'in the sauce'
60
74
  render :file => 'test/render_file_with_ivar', :use_full_path => true
61
75
  end
76
+
77
+ def render_file_not_using_full_path_with_relative_path
78
+ @secret = 'in the sauce'
79
+ render :file => 'test/../test/render_file_with_ivar', :use_full_path => true
80
+ end
62
81
 
82
+ def render_file_not_using_full_path_with_dot_in_path
83
+ @secret = 'in the sauce'
84
+ render :file => 'test/dot.directory/render_file_with_ivar', :use_full_path => true
85
+ end
86
+
63
87
  def render_xml_hello
64
88
  @name = "David"
65
89
  render :template => "test/hello"
@@ -170,6 +194,62 @@ class NewRenderTestController < ActionController::Base
170
194
  render :action => "potential_conflicts"
171
195
  end
172
196
 
197
+ def hello_world_from_rxml_using_action
198
+ render :action => "hello_world.rxml"
199
+ end
200
+
201
+ def hello_world_from_rxml_using_template
202
+ render :template => "test/hello_world.rxml"
203
+ end
204
+
205
+ helper NewRenderTestHelper
206
+ helper do
207
+ def rjs_helper_method(value)
208
+ page.visual_effect :highlight, value
209
+ end
210
+ end
211
+
212
+ def enum_rjs_test
213
+ render :update do |page|
214
+ page.select('.product').each do |value|
215
+ page.rjs_helper_method_from_module
216
+ page.rjs_helper_method(value)
217
+ page.sortable(value, :url => { :action => "order" })
218
+ page.draggable(value)
219
+ end
220
+ end
221
+ end
222
+
223
+ def delete_with_js
224
+ @project_id = 4
225
+ end
226
+
227
+ def render_js_with_explicit_template
228
+ @project_id = 4
229
+ render :template => 'test/delete_with_js'
230
+ end
231
+
232
+ def render_js_with_explicit_action_template
233
+ @project_id = 4
234
+ render :action => 'delete_with_js'
235
+ end
236
+
237
+ def update_page
238
+ render :update do |page|
239
+ page.replace_html 'balance', '$37,000,000.00'
240
+ page.visual_effect :highlight, 'balance'
241
+ end
242
+ end
243
+
244
+ def update_page_with_instance_variables
245
+ @money = '$37,000,000.00'
246
+ @div_id = 'balance'
247
+ render :update do |page|
248
+ page.replace_html @div_id, @money
249
+ page.visual_effect :highlight, @div_id
250
+ end
251
+ end
252
+
173
253
  def action_talk_to_layout
174
254
  # Action template sets variable that's picked up by layout
175
255
  end
@@ -191,10 +271,15 @@ class NewRenderTestController < ActionController::Base
191
271
  when "hello_world", "layout_test", "rendering_without_layout",
192
272
  "rendering_nothing_on_layout", "render_text_hello_world",
193
273
  "render_text_hello_world_with_layout",
274
+ "hello_world_with_layout_false",
194
275
  "partial_only", "partial_only_with_layout",
195
276
  "accessing_params_in_template",
196
277
  "accessing_params_in_template_with_layout",
197
- "render_with_explicit_template"
278
+ "render_with_explicit_template",
279
+ "render_js_with_explicit_template",
280
+ "render_js_with_explicit_action_template",
281
+ "delete_with_js", "update_page", "update_page_with_instance_variables"
282
+
198
283
  "layouts/standard"
199
284
  when "builder_layout_test"
200
285
  "layouts/builder"
@@ -243,6 +328,11 @@ class NewRenderTest < Test::Unit::TestCase
243
328
  assert_template "test/hello_world"
244
329
  end
245
330
 
331
+ def test_do_with_render_action_as_symbol
332
+ get :render_action_hello_world_as_symbol
333
+ assert_template "test/hello_world"
334
+ end
335
+
246
336
  def test_do_with_render_text
247
337
  get :render_text_hello_world
248
338
  assert_equal "hello world", @response.body
@@ -253,6 +343,11 @@ class NewRenderTest < Test::Unit::TestCase
253
343
  assert_equal "<html>hello world, I'm here!</html>", @response.body
254
344
  end
255
345
 
346
+ def test_do_with_render_action_and_layout_false
347
+ get :hello_world_with_layout_false
348
+ assert_equal 'Hello world!', @response.body
349
+ end
350
+
256
351
  def test_do_with_render_custom_code
257
352
  get :render_custom_code
258
353
  assert_response :missing
@@ -268,6 +363,16 @@ class NewRenderTest < Test::Unit::TestCase
268
363
  assert_equal "The secret is in the sauce\n", @response.body
269
364
  end
270
365
 
366
+ def test_render_file_not_using_full_path_with_relative_path
367
+ get :render_file_not_using_full_path_with_relative_path
368
+ assert_equal "The secret is in the sauce\n", @response.body
369
+ end
370
+
371
+ def test_render_file_not_using_full_path_with_dot_in_path
372
+ get :render_file_not_using_full_path_with_dot_in_path
373
+ assert_equal "The secret is in the sauce\n", @response.body
374
+ end
375
+
271
376
  def test_render_file_with_locals
272
377
  get :render_file_with_locals
273
378
  assert_equal "The secret is in the sauce\n", @response.body
@@ -305,11 +410,38 @@ class NewRenderTest < Test::Unit::TestCase
305
410
  assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
306
411
  end
307
412
 
413
+ def test_enum_rjs_test
414
+ get :enum_rjs_test
415
+ assert_equal <<-EOS.strip, @response.body
416
+ $$(".product").each(function(value, index) {
417
+ new Effect.Highlight(element,{});
418
+ new Effect.Highlight(value,{});
419
+ Sortable.create(value, {onUpdate:function(){new Ajax.Request('/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value)})}});
420
+ new Draggable(value, {});
421
+ });
422
+ EOS
423
+ end
424
+
308
425
  def test_render_xml_with_default
309
426
  get :greeting
310
427
  assert_equal "<p>This is grand!</p>\n", @response.body
311
428
  end
312
429
 
430
+ def test_render_rjs_with_default
431
+ get :delete_with_js
432
+ assert_equal %!["person"].each(Element.remove);\nnew Effect.Highlight(\"project-4\",{});!, @response.body
433
+ end
434
+
435
+ def test_render_rjs_template_explicitly
436
+ get :render_js_with_explicit_template
437
+ assert_equal %!["person"].each(Element.remove);\nnew Effect.Highlight(\"project-4\",{});!, @response.body
438
+ end
439
+
440
+ def test_rendering_rjs_action_explicitly
441
+ get :render_js_with_explicit_action_template
442
+ assert_equal %!["person"].each(Element.remove);\nnew Effect.Highlight(\"project-4\",{});!, @response.body
443
+ end
444
+
313
445
  def test_layout_rendering
314
446
  get :layout_test
315
447
  assert_equal "<html>Hello world!</html>", @response.body
@@ -437,8 +569,32 @@ class NewRenderTest < Test::Unit::TestCase
437
569
  assert_equal "world", assigns["hello"]
438
570
  end
439
571
 
572
+ def test_update_page
573
+ get :update_page
574
+ assert_template nil
575
+ assert_equal 'text/javascript; charset=UTF-8', @response.headers['Content-Type']
576
+ assert_equal 2, @response.body.split($/).length
577
+ end
578
+
579
+ def test_update_page_with_instance_variables
580
+ get :update_page_with_instance_variables
581
+ assert_template nil
582
+ assert_equal 'text/javascript; charset=UTF-8', @response.headers['Content-Type']
583
+ assert_match /balance/, @response.body
584
+ assert_match /\$37/, @response.body
585
+ end
586
+
440
587
  def test_yield_content_for
441
588
  get :yield_content_for
442
589
  assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body
443
590
  end
591
+
592
+
593
+ def test_overwritting_rendering_relative_file_with_extension
594
+ get :hello_world_from_rxml_using_template
595
+ assert_equal "<html>\n <p>Hello</p>\n</html>\n", @response.body
596
+
597
+ get :hello_world_from_rxml_using_action
598
+ assert_equal "<html>\n <p>Hello</p>\n</html>\n", @response.body
599
+ end
444
600
  end
@@ -27,6 +27,8 @@ class RedirectController < ActionController::Base
27
27
  end
28
28
 
29
29
  def rescue_errors(e) raise e end
30
+
31
+ def rescue_action(e) raise end
30
32
 
31
33
  protected
32
34
  def dashbord_url(id, message)
@@ -56,6 +58,20 @@ class RedirectTest < Test::Unit::TestCase
56
58
  assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host'
57
59
  end
58
60
 
61
+ def test_redirect_error_with_pretty_diff
62
+ get :host_redirect
63
+ begin
64
+ assert_redirected_to :action => "other_host", :only_path => true
65
+ rescue Test::Unit::AssertionFailedError => err
66
+ redirection_msg, diff_msg = err.message.scan(/<\{[^\}]+\}>/).collect { |s| s[2..-3] }
67
+ assert_match %r(:only_path=>false), redirection_msg
68
+ assert_match %r(:host=>"other.test.host"), redirection_msg
69
+ assert_match %r(:action=>"other_host"), redirection_msg
70
+ assert_match %r(:only_path=>true), diff_msg
71
+ assert_match %r(:host=>"other.test.host"), diff_msg
72
+ end
73
+ end
74
+
59
75
  def test_module_redirect
60
76
  get :module_redirect
61
77
  assert_redirect_url "http://test.host/module_test/module_redirect/hello_world"
@@ -76,6 +92,13 @@ class RedirectTest < Test::Unit::TestCase
76
92
  get :redirect_to_back
77
93
  assert_redirect_url "http://www.example.com/coming/from"
78
94
  end
95
+
96
+ def test_redirect_to_back_with_no_referer
97
+ assert_raises(ActionController::RedirectBackError) {
98
+ @request.env["HTTP_REFERER"] = nil
99
+ get :redirect_to_back
100
+ }
101
+ end
79
102
  end
80
103
 
81
104
  module ModuleTest
@@ -30,7 +30,11 @@ class TestController < ActionController::Base
30
30
  def render_action_hello_world
31
31
  render_action "hello_world"
32
32
  end
33
-
33
+
34
+ def render_action_hello_world_with_symbol
35
+ render_action :hello_world
36
+ end
37
+
34
38
  def render_text_hello_world
35
39
  render_text "hello world"
36
40
  end
@@ -111,50 +115,53 @@ class RenderTest < Test::Unit::TestCase
111
115
  def setup
112
116
  @request = ActionController::TestRequest.new
113
117
  @response = ActionController::TestResponse.new
118
+ @controller = TestController.new
114
119
 
115
120
  @request.host = "www.nextangle.com"
116
121
  end
117
122
 
118
123
  def test_simple_show
119
- @request.action = "hello_world"
120
- response = process_request
121
- assert_equal "200 OK", response.headers["Status"]
122
- assert_equal "test/hello_world", response.template.first_render
124
+ get :hello_world
125
+ assert_response 200
126
+ assert_template "test/hello_world"
123
127
  end
124
128
 
125
129
  def test_do_with_render
126
- @request.action = "render_hello_world"
127
- assert_equal "test/hello_world", process_request.template.first_render
130
+ get :render_hello_world
131
+ assert_template "test/hello_world"
128
132
  end
129
133
 
130
134
  def test_do_with_render_from_variable
131
- @request.action = "render_hello_world_from_variable"
132
- assert_equal "hello david", process_request.body
135
+ get :render_hello_world_from_variable
136
+ assert_equal "hello david", @response.body
133
137
  end
134
138
 
135
139
  def test_do_with_render_action
136
- @request.action = "render_action_hello_world"
137
- assert_equal "test/hello_world", process_request.template.first_render
140
+ get :render_action_hello_world
141
+ assert_template "test/hello_world"
142
+ end
143
+
144
+ def test_do_with_render_action_with_symbol
145
+ get :render_action_hello_world_with_symbol
146
+ assert_template "test/hello_world"
138
147
  end
139
148
 
140
149
  def test_do_with_render_text
141
- @request.action = "render_text_hello_world"
142
- assert_equal "hello world", process_request.body
150
+ get :render_text_hello_world
151
+ assert_equal "hello world", @response.body
143
152
  end
144
153
 
145
154
  def test_do_with_render_custom_code
146
- @request.action = "render_custom_code"
147
- assert_equal "404 Moved", process_request.headers["Status"]
155
+ get :render_custom_code
156
+ assert_response 404
148
157
  end
149
158
 
150
159
  def test_attempt_to_access_object_method
151
- @request.action = "clone"
152
- assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { process_request }
160
+ assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
153
161
  end
154
162
 
155
163
  def test_private_methods
156
- @request.action = "determine_layout"
157
- assert_raises(ActionController::UnknownAction, "No action responded to [determine_layout]") { process_request }
164
+ assert_raises(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
158
165
  end
159
166
 
160
167
  def test_access_to_request_in_view
@@ -163,86 +170,77 @@ class RenderTest < Test::Unit::TestCase
163
170
  ActionController::Base.view_controller_internals = false
164
171
  ActionController::Base.protected_variables_cache = nil
165
172
 
166
- @request.action = "hello_world"
167
- response = process_request
168
- assert_nil response.template.assigns["request"]
173
+ get :hello_world
174
+ assert_nil assigns["request"]
169
175
 
170
176
  ActionController::Base.view_controller_internals = true
171
177
  ActionController::Base.protected_variables_cache = nil
172
178
 
173
- @request.action = "hello_world"
174
- response = process_request
175
- assert_kind_of ActionController::AbstractRequest, response.template.assigns["request"]
179
+ get :hello_world
180
+ assert_kind_of ActionController::AbstractRequest, assigns["request"]
176
181
 
177
182
  ActionController::Base.view_controller_internals = view_internals_old_value
178
183
  ActionController::Base.protected_variables_cache = nil
179
184
  end
180
185
 
181
186
  def test_render_xml
182
- @request.action = "render_xml_hello"
183
- assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", process_request.body
187
+ get :render_xml_hello
188
+ assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
184
189
  end
185
190
 
186
191
  def test_render_xml_with_default
187
- @request.action = "greeting"
188
- assert_equal "<p>This is grand!</p>\n", process_request.body
192
+ get :greeting
193
+ assert_equal "<p>This is grand!</p>\n", @response.body
189
194
  end
190
195
 
191
196
  def test_layout_rendering
192
- @request.action = "layout_test"
193
- assert_equal "<html>Hello world!</html>", process_request.body
197
+ get :layout_test
198
+ assert_equal "<html>Hello world!</html>", @response.body
194
199
  end
195
200
 
196
201
  def test_render_xml_with_layouts
197
- @request.action = "builder_layout_test"
198
- assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", process_request.body
202
+ get :builder_layout_test
203
+ assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
199
204
  end
200
205
 
201
206
  # def test_partials_list
202
- # @request.action = "partials_list"
207
+ # get :partials_list
203
208
  # assert_equal "goodbyeHello: davidHello: marygoodbye\n", process_request.body
204
209
  # end
205
210
 
206
211
  def test_partial_only
207
- @request.action = "partial_only"
208
- assert_equal "only partial", process_request.body
212
+ get :partial_only
213
+ assert_equal "only partial", @response.body
209
214
  end
210
215
 
211
216
  def test_render_to_string
212
- @request.action = "hello_in_a_string"
213
- assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", process_request.body
217
+ get :hello_in_a_string
218
+ assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body
214
219
  end
215
220
 
216
221
  def test_render_to_string_resets_assigns
217
- @request.action = "render_to_string_test"
218
- assert_equal "The value of foo is: ::this is a test::\n", process_request.body
222
+ get :render_to_string_test
223
+ assert_equal "The value of foo is: ::this is a test::\n", @response.body
219
224
  end
220
225
 
221
226
  def test_nested_rendering
222
- @request.action = "hello_world"
223
- assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body
227
+ @controller = Fun::GamesController.new
228
+ get :hello_world
229
+ assert_equal "Living in a nested world", @response.body
224
230
  end
225
231
 
226
232
  def test_accessing_params_in_template
227
- @request.action = "accessing_params_in_template"
228
- @request.query_parameters[:name] = "David"
229
- assert_equal "Hello: David", process_request.body
233
+ get :accessing_params_in_template, :name => "David"
234
+ assert_equal "Hello: David", @response.body
230
235
  end
231
236
 
232
237
  def test_accessing_local_assigns_in_inline_template
233
- @request.action = "accessing_local_assigns_in_inline_template"
234
- @request.query_parameters[:local_name] = "Local David"
235
- assert_equal "Goodbye, Local David", process_request.body
238
+ get :accessing_local_assigns_in_inline_template, :local_name => "Local David"
239
+ assert_equal "Goodbye, Local David", @response.body
236
240
  end
237
241
 
238
242
  def test_accessing_local_assigns_in_inline_template_with_string_keys
239
- @request.action = "accessing_local_assigns_in_inline_template_with_string_keys"
240
- @request.query_parameters[:local_name] = "Local David"
241
- assert_equal "Goodbye, Local David", process_request.body
243
+ get :accessing_local_assigns_in_inline_template_with_string_keys, :local_name => "Local David"
244
+ assert_equal "Goodbye, Local David", @response.body
242
245
  end
243
-
244
- private
245
- def process_request
246
- TestController.process(@request, @response)
247
- end
248
246
  end