aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/render_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 00:51:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 00:51:02 +0000
commitc844755e5a0c3d4edfcc78f9c30ef91fa0de550a (patch)
tree4cf4890fc5af5f58dd0a6a19c0a6fea6ed39a1df /actionpack/test/controller/render_test.rb
parenta3298e5efdf33398b49933323ea3fef7ff4e9a9c (diff)
downloadrails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.gz
rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.bz2
rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.zip
Merged back the Routing branch
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/render_test.rb')
-rw-r--r--actionpack/test/controller/render_test.rb136
1 files changed, 70 insertions, 66 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index f983960e2e..afffd15793 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -2,86 +2,91 @@ require File.dirname(__FILE__) + '/../abstract_unit'
Customer = Struct.new("Customer", :name)
-class RenderTest < Test::Unit::TestCase
- class TestController < ActionController::Base
- layout :determine_layout
-
+module Fun
+ class GamesController < ActionController::Base
def hello_world
end
+ end
+end
- def render_hello_world
- render "test/hello_world"
- end
-
- def render_hello_world_from_variable
- @person = "david"
- render_text "hello #{@person}"
- end
- def render_action_hello_world
- render_action "hello_world"
- end
-
- def render_text_hello_world
- render_text "hello world"
- end
+class TestController < ActionController::Base
+ layout :determine_layout
- def render_custom_code
- render_text "hello world", "404 Moved"
- end
-
- def render_xml_hello
- @name = "David"
- render "test/hello"
- end
+ def hello_world
+ end
- def greeting
- # let's just rely on the template
- end
+ def render_hello_world
+ render "test/hello_world"
+ end
- def layout_test
- render_action "hello_world"
- end
-
- def builder_layout_test
- render_action "hello"
- end
+ def render_hello_world_from_variable
+ @person = "david"
+ render_text "hello #{@person}"
+ end
- def partials_list
- @customers = [ Customer.new("david"), Customer.new("mary") ]
- render_action "list"
- end
+ def render_action_hello_world
+ render_action "hello_world"
+ end
+
+ def render_text_hello_world
+ render_text "hello world"
+ end
- def modgreet
- end
+ def render_custom_code
+ render_text "hello world", "404 Moved"
+ end
+
+ def render_xml_hello
+ @name = "David"
+ render "test/hello"
+ end
- 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
+ def greeting
+ # let's just rely on the template
end
- TestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+ def layout_test
+ render_action "hello_world"
+ end
- class TestLayoutController < ActionController::Base
- layout "layouts/standard"
-
- def hello_world
- end
+ def builder_layout_test
+ render_action "hello"
+ end
+
+ def partials_list
+ @customers = [ Customer.new("david"), Customer.new("mary") ]
+ render_action "list"
+ end
+
+ def rescue_action(e) raise end
- def hello_world_outside_layout
+ 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 unless ActionController::MissingTemplate === e
- 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
+ end
+end
+class RenderTest < Test::Unit::TestCase
def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@@ -170,10 +175,9 @@ class RenderTest < Test::Unit::TestCase
assert_equal "Hello: davidHello: mary", process_request.body
end
- def test_module_rendering
- @request.action = "modgreet"
- @request.parameters["module"] = "scope"
- assert_equal "<p>Beautiful modules!</p>", process_request.body
+ def test_nested_rendering
+ @request.action = "hello_world"
+ assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body
end
private