1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Renamed the new_base tests

This commit is contained in:
Yehuda Katz + Carl Lerche 2009-04-29 11:42:27 -07:00
parent b692fceb6a
commit 1b45991603
4 changed files with 127 additions and 123 deletions

View file

@ -106,6 +106,7 @@ class TestController < ActionController::Base
render :template => '/shared'
end
# :ported:
def render_hello_world_from_variable
@person = "david"
render :text => "hello #{@person}"
@ -123,6 +124,7 @@ class TestController < ActionController::Base
render :action => :hello_world
end
# :ported:
def render_text_hello_world
render :text => "hello world"
end

View file

@ -1,8 +1,8 @@
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
# Tests the controller dispatching happy path
module HappyPath
class SimpleDispatchController < ActionController::Base2
module Dispatching
class SimpleController < ActionController::Base2
def index
render :text => "success"
end
@ -23,7 +23,7 @@ module HappyPath
class TestSimpleDispatch < SimpleRouteCase
get "/happy_path/simple_dispatch/index"
get "/dispatching/simple/index"
test "sets the body" do
assert_body "success"
@ -45,7 +45,7 @@ module HappyPath
# :api: plugin
class TestDirectResponseMod < SimpleRouteCase
get "/happy_path/simple_dispatch/modify_response_body"
get "/dispatching/simple/modify_response_body"
test "sets the body" do
assert_body "success"
@ -58,7 +58,7 @@ module HappyPath
# :api: plugin
class TestDirectResponseModTwice < SimpleRouteCase
get "/happy_path/simple_dispatch/modify_response_body_twice"
get "/dispatching/simple/modify_response_body_twice"
test "self.response_body= returns the body being set" do
assert_body "success!"
@ -68,23 +68,22 @@ module HappyPath
assert_header "Content-Length", "8"
end
end
end
class EmptyController < ActionController::Base2 ; end
module Submodule
class ContainedEmptyController < ActionController::Base2 ; end
end
class ControllerClassTests < Test::Unit::TestCase
def test_controller_path
assert_equal 'empty', EmptyController.controller_path
assert_equal EmptyController.controller_path, EmptyController.new.controller_path
assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path
assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path
class EmptyController < ActionController::Base2 ; end
module Submodule
class ContainedEmptyController < ActionController::Base2 ; end
end
class ControllerClassTests < Test::Unit::TestCase
def test_controller_path
assert_equal 'dispatching/empty', EmptyController.controller_path
assert_equal EmptyController.controller_path, EmptyController.new.controller_path
assert_equal 'dispatching/submodule/contained_empty', Submodule::ContainedEmptyController.controller_path
assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path
end
def test_controller_name
assert_equal 'empty', EmptyController.controller_name
assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
end
end
def test_controller_name
assert_equal 'empty', EmptyController.controller_name
assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
end
end

View file

@ -1,31 +1,30 @@
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
module HappyPath
class RenderTemplateWithoutLayoutController < ActionController::Base2
module RenderTemplate
class WithoutLayoutController < ActionController::Base2
self.view_paths = [ActionView::Template::FixturePath.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
"shared.html.erb" => "Elastica"
)]
def render_hello_world
def index
render :template => "test/basic"
end
def render_template_in_top_directory
def in_top_directory
render :template => 'shared'
end
def render_template_in_top_directory_with_slash
def in_top_directory_with_slash
render :template => '/shared'
end
end
class TestTemplateRenderWithoutLayout < SimpleRouteCase
class TestWithoutLayout < SimpleRouteCase
describe "rendering a normal template with full path without layout"
get "/happy_path/render_template_without_layout/render_hello_world"
get "/render_template/without_layout"
assert_body "Hello from basic.html.erb"
assert_status 200
end
@ -33,7 +32,7 @@ module HappyPath
class TestTemplateRenderInTopDirectory < SimpleRouteCase
describe "rendering a template not in a subdirectory"
get "/happy_path/render_template_without_layout/render_template_in_top_directory"
get "/render_template/without_layout/in_top_directory"
assert_body "Elastica"
assert_status 200
end
@ -41,12 +40,12 @@ module HappyPath
class TestTemplateRenderInTopDirectoryWithSlash < SimpleRouteCase
describe "rendering a template not in a subdirectory with a leading slash"
get "/happy_path/render_template_without_layout/render_template_in_top_directory_with_slash"
get "/render_template/without_layout/in_top_directory_with_slash"
assert_body "Elastica"
assert_status 200
end
class RenderTemplateWithLayoutController < ::ApplicationController
class WithLayoutController < ::ApplicationController
self.view_paths = [ActionView::Template::FixturePath.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
@ -55,23 +54,23 @@ module HappyPath
"layouts/greetings.html.erb" => "<%= yield %>, I wish thee well."
)]
def render_hello_world
def index
render :template => "test/basic"
end
def render_hello_world_with_layout
def with_layout
render :template => "test/basic", :layout => true
end
def render_hello_world_with_layout_false
def with_layout_false
render :template => "test/basic", :layout => false
end
def render_hello_world_with_layout_nil
def with_layout_nil
render :template => "test/basic", :layout => nil
end
def render_hello_world_with_custom_layout
def with_custom_layout
render :template => "test/basic", :layout => "greetings"
end
end
@ -79,7 +78,7 @@ module HappyPath
class TestTemplateRenderWithLayout < SimpleRouteCase
describe "rendering a normal template with full path with layout"
get "/happy_path/render_template_with_layout/render_hello_world"
get "/render_template/with_layout"
assert_body "Hello from basic.html.erb, I'm here!"
assert_status 200
end
@ -87,7 +86,7 @@ module HappyPath
class TestTemplateRenderWithLayoutTrue < SimpleRouteCase
describe "rendering a normal template with full path with layout => :true"
get "/happy_path/render_template_with_layout/render_hello_world_with_layout"
get "/render_template/with_layout/with_layout"
assert_body "Hello from basic.html.erb, I'm here!"
assert_status 200
end
@ -95,7 +94,7 @@ module HappyPath
class TestTemplateRenderWithLayoutFalse < SimpleRouteCase
describe "rendering a normal template with full path with layout => :false"
get "/happy_path/render_template_with_layout/render_hello_world_with_layout_false"
get "/render_template/with_layout/with_layout_false"
assert_body "Hello from basic.html.erb"
assert_status 200
end
@ -103,7 +102,7 @@ module HappyPath
class TestTemplateRenderWithLayoutNil < SimpleRouteCase
describe "rendering a normal template with full path with layout => :nil"
get "/happy_path/render_template_with_layout/render_hello_world_with_layout_nil"
get "/render_template/with_layout/with_layout_nil"
assert_body "Hello from basic.html.erb"
assert_status 200
end
@ -111,30 +110,29 @@ module HappyPath
class TestTemplateRenderWithCustomLayout < SimpleRouteCase
describe "rendering a normal template with full path with layout => 'greetings'"
get "/happy_path/render_template_with_layout/render_hello_world_with_custom_layout"
get "/render_template/with_layout/with_custom_layout"
assert_body "Hello from basic.html.erb, I wish thee well."
assert_status 200
end
module Compatibility
class WithoutLayoutController < ActionController::CompatibleBase2
self.view_paths = [ActionView::Template::FixturePath.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
"shared.html.erb" => "Elastica"
)]
end
def with_forward_slash
render :template => "/test/basic"
end
end
module Compatibility
class RenderTemplateWithoutLayoutController < ActionController::CompatibleBase2
self.view_paths = [ActionView::Template::FixturePath.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
"shared.html.erb" => "Elastica"
)]
def render_hello_world_with_forward_slash
render :template => "/test/basic"
class TestTemplateRenderWithForwardSlash < SimpleRouteCase
describe "rendering a normal template with full path starting with a leading slash"
get "/render_template/compatibility/without_layout/with_forward_slash"
assert_body "Hello from basic.html.erb"
assert_status 200
end
end
class TestTemplateRenderWithForwardSlash < SimpleRouteCase
describe "rendering a normal template with full path starting with a leading slash"
get "/compatibility/render_template_without_layout/render_hello_world_with_forward_slash"
assert_body "Hello from basic.html.erb"
assert_status 200
end
end

View file

@ -3,75 +3,80 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
class ApplicationController < ActionController::Base2
end
module HappyPath
class RenderTextWithoutLayoutsController < ActionController::Base2
module RenderText
class SimpleController < ActionController::Base2
self.view_paths = [ActionView::Template::FixturePath.new]
def render_hello_world
def index
render :text => "hello david"
end
end
class RenderTextWithLayoutsController < ::ApplicationController
self.view_paths = [ActionView::Template::FixturePath.new(
"layouts/application.html.erb" => "<%= yield %>, I'm here!",
"layouts/greetings.html.erb" => "<%= yield %>, I wish thee well."
)]
def render_hello_world
render :text => "hello david"
end
def render_custom_code
render :text => "hello world", :status => 404
end
def render_with_custom_code_as_string
render :text => "hello world", :status => "404 Not Found"
end
def render_text_with_nil
render :text => nil
end
def render_text_with_nil_and_status
render :text => nil, :status => 403
end
def render_text_with_false
render :text => false
end
def render_text_with_layout
render :text => "hello world", :layout => true
end
def render_text_with_layout_false
render :text => "hello world", :layout => false
end
def render_text_with_layout_nil
render :text => "hello world", :layout => nil
end
def render_text_with_custom_layout
render :text => "hello world", :layout => "greetings"
end
end
class TestSimpleTextRenderWithNoLayout < SimpleRouteCase
describe "Rendering text from a action with default options renders the text with the layout"
get "/happy_path/render_text_without_layouts/render_hello_world"
get "/render_text/simple"
assert_body "hello david"
assert_status 200
end
class WithLayoutController < ::ApplicationController
self.view_paths = [ActionView::Template::FixturePath.new(
"layouts/application.html.erb" => "<%= yield %>, I'm here!",
"layouts/greetings.html.erb" => "<%= yield %>, I wish thee well.",
"layouts/ivar.html.erb" => "<%= yield %>, <%= @ivar %>"
)]
def index
render :text => "hello david"
end
def custom_code
render :text => "hello world", :status => 404
end
def with_custom_code_as_string
render :text => "hello world", :status => "404 Not Found"
end
def with_nil
render :text => nil
end
def with_nil_and_status
render :text => nil, :status => 403
end
def with_false
render :text => false
end
def with_layout_true
render :text => "hello world", :layout => true
end
def with_layout_false
render :text => "hello world", :layout => false
end
def with_layout_nil
render :text => "hello world", :layout => nil
end
def with_custom_layout
render :text => "hello world", :layout => "greetings"
end
def with_ivar_in_layout
@ivar = "hello world"
render :text => "hello world", :layout => "ivar"
end
end
class TestSimpleTextRenderWithLayout < SimpleRouteCase
describe "Rendering text from a action with default options renders the text without the layout"
get "/happy_path/render_text_with_layouts/render_hello_world"
get "/render_text/with_layout"
assert_body "hello david"
assert_status 200
end
@ -79,7 +84,7 @@ module HappyPath
class TestTextRenderWithStatus < SimpleRouteCase
describe "Rendering text, while also providing a custom status code"
get "/happy_path/render_text_with_layouts/render_custom_code"
get "/render_text/with_layout/custom_code"
assert_body "hello world"
assert_status 404
end
@ -87,7 +92,7 @@ module HappyPath
class TestTextRenderWithNil < SimpleRouteCase
describe "Rendering text with nil returns a single space character"
get "/happy_path/render_text_with_layouts/render_text_with_nil"
get "/render_text/with_layout/with_nil"
assert_body " "
assert_status 200
end
@ -95,7 +100,7 @@ module HappyPath
class TestTextRenderWithNilAndStatus < SimpleRouteCase
describe "Rendering text with nil and custom status code returns a single space character with the status"
get "/happy_path/render_text_with_layouts/render_text_with_nil_and_status"
get "/render_text/with_layout/with_nil_and_status"
assert_body " "
assert_status 403
end
@ -103,7 +108,7 @@ module HappyPath
class TestTextRenderWithFalse < SimpleRouteCase
describe "Rendering text with false returns the string 'false'"
get "/happy_path/render_text_with_layouts/render_text_with_false"
get "/render_text/with_layout/with_false"
assert_body "false"
assert_status 200
end
@ -111,7 +116,7 @@ module HappyPath
class TestTextRenderWithLayoutTrue < SimpleRouteCase
describe "Rendering text with :layout => true"
get "/happy_path/render_text_with_layouts/render_text_with_layout"
get "/render_text/with_layout/with_layout_true"
assert_body "hello world, I'm here!"
assert_status 200
end
@ -119,7 +124,7 @@ module HappyPath
class TestTextRenderWithCustomLayout < SimpleRouteCase
describe "Rendering text with :layout => 'greetings'"
get "/happy_path/render_text_with_layouts/render_text_with_custom_layout"
get "/render_text/with_layout/with_custom_layout"
assert_body "hello world, I wish thee well."
assert_status 200
end
@ -127,7 +132,7 @@ module HappyPath
class TestTextRenderWithLayoutFalse < SimpleRouteCase
describe "Rendering text with :layout => false"
get "/happy_path/render_text_with_layouts/render_text_with_layout_false"
get "/render_text/with_layout/with_layout_false"
assert_body "hello world"
assert_status 200
end
@ -135,7 +140,7 @@ module HappyPath
class TestTextRenderWithLayoutNil < SimpleRouteCase
describe "Rendering text with :layout => nil"
get "/happy_path/render_text_with_layouts/render_text_with_layout_nil"
get "/render_text/with_layout/with_layout_nil"
assert_body "hello world"
assert_status 200
end