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 => ' '
|
render :text => ' '
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def layout_test
|
def layout_test
|
||||||
render :action => "hello_world"
|
render :action => "hello_world"
|
||||||
end
|
end
|
||||||
|
@ -299,7 +300,8 @@ class TestController < ActionController::Base
|
||||||
def builder_layout_test
|
def builder_layout_test
|
||||||
render :action => "hello", :layout => "layouts/builder"
|
render :action => "hello", :layout => "layouts/builder"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :move: test this in ActionView
|
||||||
def builder_partial_test
|
def builder_partial_test
|
||||||
render :action => "hello_world_container"
|
render :action => "hello_world_container"
|
||||||
end
|
end
|
||||||
|
@ -988,14 +990,17 @@ class RenderTest < ActionController::TestCase
|
||||||
assert_equal 'appended', @response.body
|
assert_equal 'appended', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_attempt_to_access_object_method
|
def test_attempt_to_access_object_method
|
||||||
assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
|
assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_private_methods
|
def test_private_methods
|
||||||
assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
|
assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_access_to_request_in_view
|
def test_access_to_request_in_view
|
||||||
get :accessing_request_in_template
|
get :accessing_request_in_template
|
||||||
assert_equal "Hello: www.nextangle.com", @response.body
|
assert_equal "Hello: www.nextangle.com", @response.body
|
||||||
|
@ -1006,11 +1011,13 @@ class RenderTest < ActionController::TestCase
|
||||||
assert_equal "Logger", @response.body
|
assert_equal "Logger", @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_access_to_action_name_in_view
|
def test_access_to_action_name_in_view
|
||||||
get :accessing_action_name_in_template
|
get :accessing_action_name_in_template
|
||||||
assert_equal "accessing_action_name_in_template", @response.body
|
assert_equal "accessing_action_name_in_template", @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_access_to_controller_name_in_view
|
def test_access_to_controller_name_in_view
|
||||||
get :accessing_controller_name_in_template
|
get :accessing_controller_name_in_template
|
||||||
assert_equal "test", @response.body # name is explicitly set to 'test' inside the controller.
|
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
|
assert_equal "text/javascript", @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_render_xml
|
def test_render_xml
|
||||||
get :render_xml_hello
|
get :render_xml_hello
|
||||||
assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
|
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
|
assert_equal "application/xml", @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :ported:
|
||||||
def test_render_xml_with_default
|
def test_render_xml_with_default
|
||||||
get :greeting
|
get :greeting
|
||||||
assert_equal "<p>This is grand!</p>\n", @response.body
|
assert_equal "<p>This is grand!</p>\n", @response.body
|
||||||
|
|
|
@ -5,12 +5,21 @@ module ControllerLayouts
|
||||||
|
|
||||||
self.view_paths = [ActionView::Template::FixturePath.new(
|
self.view_paths = [ActionView::Template::FixturePath.new(
|
||||||
"layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI",
|
"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
|
def index
|
||||||
render :template => "basic"
|
render :template => "basic"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def override
|
||||||
|
render :template => "basic", :layout => "override"
|
||||||
|
end
|
||||||
|
|
||||||
|
def builder_override
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestImplicitLayout < SimpleRouteCase
|
class TestImplicitLayout < SimpleRouteCase
|
||||||
|
@ -41,5 +50,10 @@ module ControllerLayouts
|
||||||
assert_status 200
|
assert_status 200
|
||||||
end
|
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
|
end
|
|
@ -3,12 +3,29 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
|
||||||
module Render
|
module Render
|
||||||
class BlankRenderController < ActionController::Base2
|
class BlankRenderController < ActionController::Base2
|
||||||
self.view_paths = [ActionView::Template::FixturePath.new(
|
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
|
def index
|
||||||
render
|
render
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
class TestBlankRender < SimpleRouteCase
|
class TestBlankRender < SimpleRouteCase
|
||||||
|
@ -36,13 +53,36 @@ module Render
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestRenderObjectMethod < SimpleRouteCase
|
class TestOnlyRenderPublicActions < SimpleRouteCase
|
||||||
describe "Methods on Object are not actions"
|
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
|
assert_raises(AbstractController::ActionNotFound) do
|
||||||
get "/render/blank_render/clone"
|
get "/render/blank_render/clone"
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
Loading…
Reference in a new issue