From 88a3343ed57c01ca358da8473d15fc4d2b4a5bff Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 15 Feb 2005 01:24:55 +0000 Subject: Backed out of routing merge.. investigating missing patches git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@616 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/render_test.rb | 136 +++++++++++++++--------------- 1 file changed, 66 insertions(+), 70 deletions(-) (limited to 'actionpack/test/controller/render_test.rb') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index afffd15793..f983960e2e 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -2,91 +2,86 @@ require File.dirname(__FILE__) + '/../abstract_unit' Customer = Struct.new("Customer", :name) -module Fun - class GamesController < ActionController::Base +class RenderTest < Test::Unit::TestCase + class TestController < ActionController::Base + layout :determine_layout + def hello_world end - end -end + def render_hello_world + render "test/hello_world" + end -class TestController < ActionController::Base - layout :determine_layout - - def hello_world - end + def render_hello_world_from_variable + @person = "david" + render_text "hello #{@person}" + end - def render_hello_world - render "test/hello_world" - end + def render_action_hello_world + render_action "hello_world" + end + + def render_text_hello_world + render_text "hello world" + end - def render_hello_world_from_variable - @person = "david" - render_text "hello #{@person}" - end + def render_custom_code + render_text "hello world", "404 Moved" + end + + def render_xml_hello + @name = "David" + render "test/hello" + end - def render_action_hello_world - render_action "hello_world" - end - - def render_text_hello_world - render_text "hello world" - end + def greeting + # let's just rely on the template + end - def render_custom_code - render_text "hello world", "404 Moved" - end - - def render_xml_hello - @name = "David" - render "test/hello" - end + def layout_test + render_action "hello_world" + end + + def builder_layout_test + render_action "hello" + end - def greeting - # let's just rely on the template - end + def partials_list + @customers = [ Customer.new("david"), Customer.new("mary") ] + render_action "list" + end - def layout_test - render_action "hello_world" - end - - def builder_layout_test - render_action "hello" - end + def modgreet + end - def partials_list - @customers = [ Customer.new("david"), Customer.new("mary") ] - render_action "list" + def rescue_action(e) raise end + + private + def determine_layout + case action_name + when "layout_test": "layouts/standard" + when "builder_layout_test": "layouts/builder" + end + end end - def rescue_action(e) raise end + TestController.template_root = File.dirname(__FILE__) + "/../fixtures/" + + class TestLayoutController < ActionController::Base + layout "layouts/standard" - private - def determine_layout - case action_name - when "layout_test": "layouts/standard" - when "builder_layout_test": "layouts/builder" - end + def hello_world + end + + def hello_world_outside_layout end -end - -TestController.template_root = File.dirname(__FILE__) + "/../fixtures/" - -class TestLayoutController < ActionController::Base - layout "layouts/standard" - - def hello_world - end - - def hello_world_outside_layout - end - def rescue_action(e) - raise unless ActionController::MissingTemplate === e + def rescue_action(e) + raise unless ActionController::MissingTemplate === e + end end -end -class RenderTest < Test::Unit::TestCase def setup @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @@ -175,9 +170,10 @@ class RenderTest < Test::Unit::TestCase assert_equal "Hello: davidHello: mary", process_request.body end - def test_nested_rendering - @request.action = "hello_world" - assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body + def test_module_rendering + @request.action = "modgreet" + @request.parameters["module"] = "scope" + assert_equal "

Beautiful modules!

", process_request.body end private -- cgit v1.2.3