mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Committing the last changes before we start trying to get the old tests to pass on the new base
This commit is contained in:
parent
4ee3e5b094
commit
69fd669165
3 changed files with 70 additions and 7 deletions
|
@ -292,6 +292,7 @@ class TestController < ActionController::Base
|
|||
render :text => ' '
|
||||
end
|
||||
|
||||
# :ported:
|
||||
def layout_test
|
||||
render :action => "hello_world"
|
||||
end
|
||||
|
@ -300,6 +301,7 @@ class TestController < ActionController::Base
|
|||
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
|
||||
|
|
|
@ -5,12 +5,21 @@ module ControllerLayouts
|
|||
|
||||
self.view_paths = [ActionView::Template::FixturePath.new(
|
||||
"layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI",
|
||||
"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
|
|
@ -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
|
Loading…
Reference in a new issue