Renamed the new_base tests

上级 b692fceb
......@@ -106,6 +106,7 @@ def render_template_in_top_directory_with_slash
render :template => '/shared'
end
# :ported:
def render_hello_world_from_variable
@person = "david"
render :text => "hello #{@person}"
......@@ -123,6 +124,7 @@ def render_action_hello_world_with_symbol
render :action => :hello_world
end
# :ported:
def render_text_hello_world
render :text => "hello world"
end
......
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 @@ def modify_response_headers
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 @@ class TestSimpleDispatch < SimpleRouteCase
# :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 @@ class TestDirectResponseMod < SimpleRouteCase
# :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 @@ class TestDirectResponseModTwice < SimpleRouteCase
assert_header "Content-Length", "8"
end
end
end
class EmptyController < ActionController::Base2 ; end
module Submodule
class ContainedEmptyController < ActionController::Base2 ; 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 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
\ No newline at end of file
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 @@ class TestTemplateRenderWithoutLayout < SimpleRouteCase
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 @@ class TestTemplateRenderInTopDirectory < SimpleRouteCase
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 @@ class RenderTemplateWithLayoutController < ::ApplicationController
"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 @@ def render_hello_world_with_custom_layout
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 @@ class TestTemplateRenderWithLayout < SimpleRouteCase
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 @@ class TestTemplateRenderWithLayoutTrue < SimpleRouteCase
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 @@ class TestTemplateRenderWithLayoutFalse < SimpleRouteCase
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 @@ class TestTemplateRenderWithLayoutNil < SimpleRouteCase
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
\ No newline at end of file
......@@ -3,75 +3,80 @@
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
class TestSimpleTextRenderWithNoLayout < SimpleRouteCase
describe "Rendering text from a action with default options renders the text with the layout"
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/greetings.html.erb" => "<%= yield %>, I wish thee well.",
"layouts/ivar.html.erb" => "<%= yield %>, <%= @ivar %>"
)]
def render_hello_world
def index
render :text => "hello david"
end
def render_custom_code
def custom_code
render :text => "hello world", :status => 404
end
def render_with_custom_code_as_string
def with_custom_code_as_string
render :text => "hello world", :status => "404 Not Found"
end
def render_text_with_nil
def with_nil
render :text => nil
end
def render_text_with_nil_and_status
def with_nil_and_status
render :text => nil, :status => 403
end
def render_text_with_false
def with_false
render :text => false
end
def render_text_with_layout
def with_layout_true
render :text => "hello world", :layout => true
end
def render_text_with_layout_false
def with_layout_false
render :text => "hello world", :layout => false
end
def render_text_with_layout_nil
def with_layout_nil
render :text => "hello world", :layout => nil
end
def render_text_with_custom_layout
def 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"
assert_body "hello david"
assert_status 200
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 @@ class TestSimpleTextRenderWithLayout < SimpleRouteCase
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 @@ class TestTextRenderWithStatus < SimpleRouteCase
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 @@ class TestTextRenderWithNil < SimpleRouteCase
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 @@ class TestTextRenderWithNilAndStatus < SimpleRouteCase
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 @@ class TestTextRenderWithFalse < SimpleRouteCase
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 @@ class TestTextRenderWithLayoutTrue < SimpleRouteCase
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 @@ class TestTextRenderWithCustomLayout < SimpleRouteCase
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 @@ class TestTextRenderWithLayoutFalse < SimpleRouteCase
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册