diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/controller/render_test.rb | 11 | ||||
-rw-r--r-- | actionpack/test/new_base/render_layout_test.rb | 18 | ||||
-rw-r--r-- | actionpack/test/new_base/render_test.rb | 48 |
3 files changed, 70 insertions, 7 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index e6b2ee7e9f..fb9b121fc9 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -292,6 +292,7 @@ class TestController < ActionController::Base render :text => ' ' end + # :ported: def layout_test render :action => "hello_world" end @@ -299,7 +300,8 @@ class TestController < ActionController::Base def builder_layout_test render :action => "hello", :layout => "layouts/builder" end - + + # :move: test this in ActionView def builder_partial_test render :action => "hello_world_container" end @@ -988,14 +990,17 @@ class RenderTest < ActionController::TestCase assert_equal 'appended', @response.body end + # :ported: def test_attempt_to_access_object_method assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } end + # :ported: def test_private_methods assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout } end + # :ported: def test_access_to_request_in_view get :accessing_request_in_template assert_equal "Hello: www.nextangle.com", @response.body @@ -1006,11 +1011,13 @@ class RenderTest < ActionController::TestCase assert_equal "Logger", @response.body end + # :ported: def test_access_to_action_name_in_view get :accessing_action_name_in_template assert_equal "accessing_action_name_in_template", @response.body end + # :ported: def test_access_to_controller_name_in_view get :accessing_controller_name_in_template assert_equal "test", @response.body # name is explicitly set to 'test' inside the controller. @@ -1022,6 +1029,7 @@ class RenderTest < ActionController::TestCase assert_equal "text/javascript", @response.content_type end + # :ported: def test_render_xml get :render_xml_hello assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body @@ -1034,6 +1042,7 @@ class RenderTest < ActionController::TestCase assert_equal "application/xml", @response.content_type end + # :ported: def test_render_xml_with_default get :greeting assert_equal "<p>This is grand!</p>\n", @response.body diff --git a/actionpack/test/new_base/render_layout_test.rb b/actionpack/test/new_base/render_layout_test.rb index 07ea2f191e..5d28926cc6 100644 --- a/actionpack/test/new_base/render_layout_test.rb +++ b/actionpack/test/new_base/render_layout_test.rb @@ -5,12 +5,21 @@ module ControllerLayouts self.view_paths = [ActionView::Template::FixturePath.new( "layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI", - "basic.html.erb" => "Hello world!" + "layouts/override.html.erb" => "Override! <%= yield %>", + "basic.html.erb" => "Hello world!" )] def index render :template => "basic" end + + def override + render :template => "basic", :layout => "override" + end + + def builder_override + + end end class TestImplicitLayout < SimpleRouteCase @@ -41,5 +50,10 @@ module ControllerLayouts assert_status 200 end - + class TestOverridingImplicitLayout < SimpleRouteCase + describe "overriding an implicit layout with render :layout option" + + get "/controller_layouts/implicit/override" + assert_body "Override! Hello world!" + end end
\ No newline at end of file diff --git a/actionpack/test/new_base/render_test.rb b/actionpack/test/new_base/render_test.rb index bc7203f294..647aa01628 100644 --- a/actionpack/test/new_base/render_test.rb +++ b/actionpack/test/new_base/render_test.rb @@ -3,12 +3,29 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module Render class BlankRenderController < ActionController::Base2 self.view_paths = [ActionView::Template::FixturePath.new( - "render/blank_render/index.html.erb" => "Hello world!" + "render/blank_render/index.html.erb" => "Hello world!", + "render/blank_render/access_request.html.erb" => "The request: <%= request.method.to_s.upcase %>", + "render/blank_render/access_action_name.html.erb" => "Action Name: <%= action_name %>", + "render/blank_render/access_controller_name.html.erb" => "Controller Name: <%= controller_name %>" )] def index render end + + def access_request + render :action => "access_request" + end + + def render_action_name + render :action => "access_action_name" + end + + private + + def secretz + render :text => "FAIL WHALE!" + end end class TestBlankRender < SimpleRouteCase @@ -36,13 +53,36 @@ module Render end end - class TestRenderObjectMethod < SimpleRouteCase - describe "Methods on Object are not actions" + class TestOnlyRenderPublicActions < SimpleRouteCase + describe "Only public methods on actual controllers are callable actions" - test "raises an exception" do + test "raises an exception when a method of Object is called" do assert_raises(AbstractController::ActionNotFound) do get "/render/blank_render/clone" end end + + test "raises an exception when a private method is called" do + assert_raises(AbstractController::ActionNotFound) do + get "/render/blank_render/secretz" + end + end + end + + class TestVariousObjectsAvailableInView < SimpleRouteCase + test "The request object is accessible in the view" do + get "/render/blank_render/access_request" + assert_body "The request: GET" + end + + test "The action_name is accessible in the view" do + get "/render/blank_render/render_action_name" + assert_body "Action Name: render_action_name" + end + + test "The controller_name is accessible in the view" do + get "/render/blank_render/access_controller_name" + assert_body "Controller Name: blank_render" + end end end
\ No newline at end of file |