aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/new_base
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/new_base')
-rw-r--r--actionpack/test/new_base/base_test.rb90
-rw-r--r--actionpack/test/new_base/render_action_test.rb325
-rw-r--r--actionpack/test/new_base/render_implicit_action_test.rb16
-rw-r--r--actionpack/test/new_base/render_layout_test.rb45
-rw-r--r--actionpack/test/new_base/render_template_test.rb133
-rw-r--r--actionpack/test/new_base/render_text_test.rb144
-rw-r--r--actionpack/test/new_base/test_helper.rb144
7 files changed, 897 insertions, 0 deletions
diff --git a/actionpack/test/new_base/base_test.rb b/actionpack/test/new_base/base_test.rb
new file mode 100644
index 0000000000..4f46cb6492
--- /dev/null
+++ b/actionpack/test/new_base/base_test.rb
@@ -0,0 +1,90 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+# Tests the controller dispatching happy path
+module HappyPath
+ class SimpleDispatchController < ActionController::Base2
+ def index
+ render :text => "success"
+ end
+
+ def modify_response_body
+ self.response_body = "success"
+ end
+
+ def modify_response_body_twice
+ ret = (self.response_body = "success")
+ self.response_body = "#{ret}!"
+ end
+
+ def modify_response_headers
+
+ end
+ end
+
+ class TestSimpleDispatch < SimpleRouteCase
+
+ get "/happy_path/simple_dispatch/index"
+
+ test "sets the body" do
+ assert_body "success"
+ end
+
+ test "sets the status code" do
+ assert_status 200
+ end
+
+ test "sets the content type" do
+ assert_content_type Mime::HTML
+ end
+
+ test "sets the content length" do
+ assert_header "Content-Length", 7
+ end
+
+ end
+
+ # :api: plugin
+ class TestDirectResponseMod < SimpleRouteCase
+ get "/happy_path/simple_dispatch/modify_response_body"
+
+ test "sets the body" do
+ assert_body "success"
+ end
+
+ test "setting the body manually sets the content length" do
+ assert_header "Content-Length", 7
+ end
+ end
+
+ # :api: plugin
+ class TestDirectResponseModTwice < SimpleRouteCase
+ get "/happy_path/simple_dispatch/modify_response_body_twice"
+
+ test "self.response_body= returns the body being set" do
+ assert_body "success!"
+ end
+
+ test "updating the response body updates the content length" do
+ 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
+ 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
diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb
new file mode 100644
index 0000000000..2bfb374a31
--- /dev/null
+++ b/actionpack/test/new_base/render_action_test.rb
@@ -0,0 +1,325 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+module RenderAction
+
+ # This has no layout and it works
+ class BasicController < ActionController::Base2
+
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "render_action/basic/hello_world.html.erb" => "Hello world!"
+ )]
+
+ def hello_world
+ render :action => "hello_world"
+ end
+
+ def hello_world_as_string
+ render "hello_world"
+ end
+
+ def hello_world_as_string_with_options
+ render "hello_world", :status => 404
+ end
+
+ def hello_world_as_symbol
+ render :hello_world
+ end
+
+ def hello_world_with_symbol
+ render :action => :hello_world
+ end
+
+ def hello_world_with_layout
+ render :action => "hello_world", :layout => true
+ end
+
+ def hello_world_with_layout_false
+ render :action => "hello_world", :layout => false
+ end
+
+ def hello_world_with_layout_nil
+ render :action => "hello_world", :layout => nil
+ end
+
+ def hello_world_with_custom_layout
+ render :action => "hello_world", :layout => "greetings"
+ end
+
+ end
+
+ class TestBasic < SimpleRouteCase
+ describe "Rendering an action using :action => <String>"
+
+ get "/render_action/basic/hello_world"
+ assert_body "Hello world!"
+ assert_status 200
+ end
+
+ class TestWithString < SimpleRouteCase
+ describe "Render an action using 'hello_world'"
+
+ get "/render_action/basic/hello_world_as_string"
+ assert_body "Hello world!"
+ assert_status 200
+ end
+
+ class TestWithStringAndOptions < SimpleRouteCase
+ describe "Render an action using 'hello_world'"
+
+ get "/render_action/basic/hello_world_as_string_with_options"
+ assert_body "Hello world!"
+ assert_status 404
+ end
+
+ class TestAsSymbol < SimpleRouteCase
+ describe "Render an action using :hello_world"
+
+ get "/render_action/basic/hello_world_as_symbol"
+ assert_body "Hello world!"
+ assert_status 200
+ end
+
+ class TestWithSymbol < SimpleRouteCase
+ describe "Render an action using :action => :hello_world"
+
+ get "/render_action/basic/hello_world_with_symbol"
+ assert_body "Hello world!"
+ assert_status 200
+ end
+
+ class TestLayoutTrue < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => true"
+
+ test "raises an exception when requesting a layout and none exist" do
+ assert_raise(ArgumentError, /no default layout for RenderAction::BasicController in/) do
+ get "/render_action/basic/hello_world_with_layout"
+ end
+ end
+ end
+
+ class TestLayoutFalse < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => false"
+
+ get "/render_action/basic/hello_world_with_layout_false"
+ assert_body "Hello world!"
+ assert_status 200
+ end
+
+ class TestLayoutNil < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => :nil"
+
+ get "/render_action/basic/hello_world_with_layout_nil"
+ assert_body "Hello world!"
+ assert_status 200
+ end
+
+ class TestCustomLayout < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => 'greetings'"
+
+ test "raises an exception when requesting a layout that does not exist" do
+ assert_raise(ActionView::MissingTemplate) { get "/render_action/basic/hello_world_with_custom_layout" }
+ end
+ end
+
+end
+
+module RenderActionWithApplicationLayout
+
+ # # ==== Render actions with layouts ====
+
+ class BasicController < ::ApplicationController
+ # Set the view path to an application view structure with layouts
+ self.view_paths = self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "render_action_with_application_layout/basic/hello_world.html.erb" => "Hello World!",
+ "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI",
+ "layouts/greetings.html.erb" => "Greetings <%= yield %> Bai"
+ )]
+
+ def hello_world
+ render :action => "hello_world"
+ end
+
+ def hello_world_with_layout
+ render :action => "hello_world", :layout => true
+ end
+
+ def hello_world_with_layout_false
+ render :action => "hello_world", :layout => false
+ end
+
+ def hello_world_with_layout_nil
+ render :action => "hello_world", :layout => nil
+ end
+
+ def hello_world_with_custom_layout
+ render :action => "hello_world", :layout => "greetings"
+ end
+ end
+
+ class TestDefaultLayout < SimpleRouteCase
+ describe %(
+ Render hello_world and implicitly use application.html.erb as a layout if
+ no layout is specified and no controller layout is present
+ )
+
+ get "/render_action_with_application_layout/basic/hello_world"
+ assert_body "OHAI Hello World! KTHXBAI"
+ assert_status 200
+ end
+
+ class TestLayoutTrue < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => true"
+
+ get "/render_action_with_application_layout/basic/hello_world_with_layout"
+ assert_body "OHAI Hello World! KTHXBAI"
+ assert_status 200
+ end
+
+ class TestLayoutFalse < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => false"
+
+ get "/render_action_with_application_layout/basic/hello_world_with_layout_false"
+ assert_body "Hello World!"
+ assert_status 200
+ end
+
+ class TestLayoutNil < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => :nil"
+
+ get "/render_action_with_application_layout/basic/hello_world_with_layout_nil"
+ assert_body "Hello World!"
+ assert_status 200
+ end
+
+ class TestCustomLayout < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => 'greetings'"
+
+ get "/render_action_with_application_layout/basic/hello_world_with_custom_layout"
+ assert_body "Greetings Hello World! Bai"
+ assert_status 200
+ end
+
+end
+
+module RenderActionWithControllerLayout
+
+ class BasicController < ActionController::Base2
+ self.view_paths = self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "render_action_with_controller_layout/basic/hello_world.html.erb" => "Hello World!",
+ "layouts/render_action_with_controller_layout/basic.html.erb" => "With Controller Layout! <%= yield %> KTHXBAI"
+ )]
+
+ def hello_world
+ render :action => "hello_world"
+ end
+
+ def hello_world_with_layout
+ render :action => "hello_world", :layout => true
+ end
+
+ def hello_world_with_layout_false
+ render :action => "hello_world", :layout => false
+ end
+
+ def hello_world_with_layout_nil
+ render :action => "hello_world", :layout => nil
+ end
+
+ def hello_world_with_custom_layout
+ render :action => "hello_world", :layout => "greetings"
+ end
+ end
+
+ class TestControllerLayout < SimpleRouteCase
+ describe "Render hello_world and implicitly use <controller_path>.html.erb as a layout."
+
+ get "/render_action_with_controller_layout/basic/hello_world"
+ assert_body "With Controller Layout! Hello World! KTHXBAI"
+ assert_status 200
+ end
+
+ class TestLayoutTrue < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => true"
+
+ get "/render_action_with_controller_layout/basic/hello_world_with_layout"
+ assert_body "With Controller Layout! Hello World! KTHXBAI"
+ assert_status 200
+ end
+
+ class TestLayoutFalse < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => false"
+
+ get "/render_action_with_controller_layout/basic/hello_world_with_layout_false"
+ assert_body "Hello World!"
+ assert_status 200
+ end
+
+ class TestLayoutNil < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => :nil"
+
+ get "/render_action_with_controller_layout/basic/hello_world_with_layout_nil"
+ assert_body "Hello World!"
+ assert_status 200
+ end
+
+end
+
+module RenderActionWithBothLayouts
+
+ class BasicController < ActionController::Base2
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new({
+ "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!",
+ "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI",
+ "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> KTHXBAI"
+ })]
+
+ def hello_world
+ render :action => "hello_world"
+ end
+
+ def hello_world_with_layout
+ render :action => "hello_world", :layout => true
+ end
+
+ def hello_world_with_layout_false
+ render :action => "hello_world", :layout => false
+ end
+
+ def hello_world_with_layout_nil
+ render :action => "hello_world", :layout => nil
+ end
+ end
+
+ class TestControllerLayoutFirst < SimpleRouteCase
+ describe "Render hello_world and implicitly use <controller_path>.html.erb over application.html.erb as a layout"
+
+ get "/render_action_with_both_layouts/basic/hello_world"
+ assert_body "With Controller Layout! Hello World! KTHXBAI"
+ assert_status 200
+ end
+
+ class TestLayoutTrue < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => true"
+
+ get "/render_action_with_both_layouts/basic/hello_world_with_layout"
+ assert_body "With Controller Layout! Hello World! KTHXBAI"
+ assert_status 200
+ end
+
+ class TestLayoutFalse < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => false"
+
+ get "/render_action_with_both_layouts/basic/hello_world_with_layout_false"
+ assert_body "Hello World!"
+ assert_status 200
+ end
+
+ class TestLayoutNil < SimpleRouteCase
+ describe "rendering a normal template with full path with layout => :nil"
+
+ get "/render_action_with_both_layouts/basic/hello_world_with_layout_nil"
+ assert_body "Hello World!"
+ assert_status 200
+ end
+
+end \ No newline at end of file
diff --git a/actionpack/test/new_base/render_implicit_action_test.rb b/actionpack/test/new_base/render_implicit_action_test.rb
new file mode 100644
index 0000000000..798505b539
--- /dev/null
+++ b/actionpack/test/new_base/render_implicit_action_test.rb
@@ -0,0 +1,16 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+module HappyPath
+
+ class RenderImplicitActionController < ActionController::Base2
+ # No actions yet, they are implicit
+ end
+
+ class TestRendersActionImplicitly < SimpleRouteCase
+
+ test "renders action implicitly" do
+ assert true
+ end
+
+ end
+end \ No newline at end of file
diff --git a/actionpack/test/new_base/render_layout_test.rb b/actionpack/test/new_base/render_layout_test.rb
new file mode 100644
index 0000000000..facf67ea85
--- /dev/null
+++ b/actionpack/test/new_base/render_layout_test.rb
@@ -0,0 +1,45 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+module ControllerLayouts
+ class ImplicitController < ::ApplicationController
+
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI",
+ "basic.html.erb" => "Hello world!"
+ )]
+
+ def index
+ render :template => "basic"
+ end
+ end
+
+ class TestImplicitLayout < SimpleRouteCase
+ describe "rendering a normal template, but using the implicit layout"
+
+ get "/controller_layouts/implicit/index"
+ assert_body "OMG Hello world! KTHXBAI"
+ assert_status 200
+ end
+
+ class ImplicitNameController < ::ApplicationController
+
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "layouts/controller_layouts/implicit_name.html.erb" => "OMGIMPLICIT <%= yield %> KTHXBAI",
+ "basic.html.erb" => "Hello world!"
+ )]
+
+ def index
+ render :template => "basic"
+ end
+ end
+
+ class TestImplicitNamedLayout < SimpleRouteCase
+ describe "rendering a normal template, but using an implicit NAMED layout"
+
+ get "/controller_layouts/implicit_name/index"
+ assert_body "OMGIMPLICIT Hello world! KTHXBAI"
+ assert_status 200
+ end
+
+
+end \ No newline at end of file
diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb
new file mode 100644
index 0000000000..c6c0269b40
--- /dev/null
+++ b/actionpack/test/new_base/render_template_test.rb
@@ -0,0 +1,133 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+module HappyPath
+
+ class RenderTemplateWithoutLayoutController < ActionController::Base2
+
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "test/basic.html.erb" => "Hello from basic.html.erb",
+ "shared.html.erb" => "Elastica"
+ )]
+
+ def render_hello_world
+ render :template => "test/basic"
+ end
+
+ def render_hello_world_with_forward_slash
+ render :template => "/test/basic"
+ end
+
+ def render_template_in_top_directory
+ render :template => 'shared'
+ end
+
+ def render_template_in_top_directory_with_slash
+ render :template => '/shared'
+ end
+ end
+
+ class TestTemplateRenderWithoutLayout < SimpleRouteCase
+ describe "rendering a normal template with full path without layout"
+
+ get "/happy_path/render_template_without_layout/render_hello_world"
+ assert_body "Hello from basic.html.erb"
+ assert_status 200
+ end
+
+ class TestTemplateRenderWithForwardSlash < SimpleRouteCase
+ describe "rendering a normal template with full path starting with a leading slash"
+
+ get "/happy_path/render_template_without_layout/render_hello_world_with_forward_slash"
+ assert_body "Hello from basic.html.erb"
+ assert_status 200
+ end
+
+ class TestTemplateRenderInTopDirectory < SimpleRouteCase
+ describe "rendering a template not in a subdirectory"
+
+ get "/happy_path/render_template_without_layout/render_template_in_top_directory"
+ assert_body "Elastica"
+ assert_status 200
+ end
+
+ 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"
+ assert_body "Elastica"
+ assert_status 200
+ end
+
+ class RenderTemplateWithLayoutController < ::ApplicationController
+
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "test/basic.html.erb" => "Hello from basic.html.erb",
+ "shared.html.erb" => "Elastica",
+ "layouts/application.html.erb" => "<%= yield %>, I'm here!",
+ "layouts/greetings.html.erb" => "<%= yield %>, I wish thee well."
+ )]
+
+ def render_hello_world
+ render :template => "test/basic"
+ end
+
+ def render_hello_world_with_layout
+ render :template => "test/basic", :layout => true
+ end
+
+ def render_hello_world_with_layout_false
+ render :template => "test/basic", :layout => false
+ end
+
+ def render_hello_world_with_layout_nil
+ render :template => "test/basic", :layout => nil
+ end
+
+ def render_hello_world_with_custom_layout
+ render :template => "test/basic", :layout => "greetings"
+ end
+ end
+
+ class TestTemplateRenderWithLayout < SimpleRouteCase
+ describe "rendering a normal template with full path with layout"
+
+ get "/happy_path/render_template_with_layout/render_hello_world"
+ assert_body "Hello from basic.html.erb, I'm here!"
+ assert_status 200
+ end
+
+ 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"
+ assert_body "Hello from basic.html.erb, I'm here!"
+ assert_status 200
+ end
+
+ 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"
+ assert_body "Hello from basic.html.erb"
+ assert_status 200
+ end
+
+ 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"
+ assert_body "Hello from basic.html.erb"
+ assert_status 200
+ end
+
+ 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"
+ assert_body "Hello from basic.html.erb, I wish thee well."
+ assert_status 200
+ end
+
+
+
+end \ No newline at end of file
diff --git a/actionpack/test/new_base/render_text_test.rb b/actionpack/test/new_base/render_text_test.rb
new file mode 100644
index 0000000000..a20ca5fb8c
--- /dev/null
+++ b/actionpack/test/new_base/render_text_test.rb
@@ -0,0 +1,144 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+class ApplicationController < ActionController::Base2
+end
+
+module HappyPath
+
+ class RenderTextWithoutLayoutsController < ActionController::Base2
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new]
+
+ def render_hello_world
+ render :text => "hello david"
+ end
+ end
+
+ class RenderTextWithLayoutsController < ::ApplicationController
+ self.view_paths = [ActionView::FixtureTemplate::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"
+ assert_body "hello david"
+ assert_status 200
+ 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"
+ assert_body "hello david"
+ assert_status 200
+ end
+
+ class TestTextRenderWithStatus < SimpleRouteCase
+ describe "Rendering text, while also providing a custom status code"
+
+ get "/happy_path/render_text_with_layouts/render_custom_code"
+ assert_body "hello world"
+ assert_status 404
+ end
+
+ class TestTextRenderWithNil < SimpleRouteCase
+ describe "Rendering text with nil returns a single space character"
+
+ get "/happy_path/render_text_with_layouts/render_text_with_nil"
+ assert_body " "
+ assert_status 200
+ end
+
+ 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"
+ assert_body " "
+ assert_status 403
+ end
+
+ class TestTextRenderWithFalse < SimpleRouteCase
+ describe "Rendering text with false returns the string 'false'"
+
+ get "/happy_path/render_text_with_layouts/render_text_with_false"
+ assert_body "false"
+ assert_status 200
+ end
+
+ class TestTextRenderWithLayoutTrue < SimpleRouteCase
+ describe "Rendering text with :layout => true"
+
+ get "/happy_path/render_text_with_layouts/render_text_with_layout"
+ assert_body "hello world, I'm here!"
+ assert_status 200
+ end
+
+ class TestTextRenderWithCustomLayout < SimpleRouteCase
+ describe "Rendering text with :layout => 'greetings'"
+
+ get "/happy_path/render_text_with_layouts/render_text_with_custom_layout"
+ assert_body "hello world, I wish thee well."
+ assert_status 200
+ end
+
+ class TestTextRenderWithLayoutFalse < SimpleRouteCase
+ describe "Rendering text with :layout => false"
+
+ get "/happy_path/render_text_with_layouts/render_text_with_layout_false"
+ assert_body "hello world"
+ assert_status 200
+ end
+
+ class TestTextRenderWithLayoutNil < SimpleRouteCase
+ describe "Rendering text with :layout => nil"
+
+ get "/happy_path/render_text_with_layouts/render_text_with_layout_nil"
+ assert_body "hello world"
+ assert_status 200
+ end
+end
+
+ActionController::Base2.app_loaded! \ No newline at end of file
diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb
new file mode 100644
index 0000000000..d29449ddc1
--- /dev/null
+++ b/actionpack/test/new_base/test_helper.rb
@@ -0,0 +1,144 @@
+$:.unshift(File.dirname(__FILE__) + '/../../lib')
+$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib')
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'test/unit'
+require 'active_support'
+require 'active_support/test_case'
+require 'action_controller'
+require 'action_view/base'
+require 'fixture_template'
+
+begin
+ require 'ruby-debug'
+ Debugger.settings[:autoeval] = true
+ Debugger.start
+rescue LoadError
+ # Debugging disabled. `gem install ruby-debug` to enable.
+end
+
+require 'action_controller/abstract'
+require 'action_controller/new_base'
+require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
+
+require 'rubygems'
+require 'rack/test'
+
+module ActionController
+ class Base2 < AbstractBase
+ use AbstractController::Callbacks
+ use AbstractController::Helpers
+ use AbstractController::Logger
+
+ use ActionController::HideActions
+ use ActionController::UrlFor
+ use ActionController::Renderer
+ use ActionController::Layouts
+
+ def self.inherited(klass)
+ ::ActionController::Base2.subclasses << klass.to_s
+ super
+ end
+
+ def self.subclasses
+ @subclasses ||= []
+ end
+
+ def self.app_loaded!
+ @subclasses.each do |subclass|
+ subclass.constantize._write_layout_method
+ end
+ end
+
+ # append_view_path File.join(File.dirname(__FILE__), '..', 'fixtures')
+
+ CORE_METHODS = self.public_instance_methods
+ end
+end
+
+# Temporary base class
+class Rack::TestCase < ActiveSupport::TestCase
+ include Rack::Test::Methods
+
+ setup do
+ ActionController::Base.session_options[:key] = "abc"
+ ActionController::Base.session_options[:secret] = ("*" * 30)
+
+ controllers = ActionController::Base2.subclasses.map do |k|
+ k.underscore.sub(/_controller$/, '')
+ end
+
+ ActionController::Routing.use_controllers!(controllers)
+
+ # Move into a bootloader
+ AbstractController::Base.subclasses.each do |klass|
+ klass = klass.constantize
+ next unless klass < AbstractController::Layouts
+ klass.class_eval do
+ _write_layout_method
+ end
+ end
+ end
+
+ def app
+ @app ||= ActionController::Dispatcher.new
+ end
+
+ def self.get(url)
+ setup do |test|
+ test.get url
+ end
+ end
+
+ def assert_body(body)
+ assert_equal [body], last_response.body
+ end
+
+ def self.assert_body(body)
+ test "body is set to '#{body}'" do
+ assert_body body
+ end
+ end
+
+ def assert_status(code)
+ assert_equal code, last_response.status
+ end
+
+ def self.assert_status(code)
+ test "status code is set to #{code}" do
+ assert_status code
+ end
+ end
+
+ def assert_content_type(type)
+ assert_equal type, last_response.headers["Content-Type"]
+ end
+
+ def self.assert_content_type(type)
+ test "content type is set to #{type}" do
+ assert_content_type(type)
+ end
+ end
+
+ def assert_header(name, value)
+ assert_equal value, last_response.headers[name]
+ end
+
+ def self.assert_header(name, value)
+ test "'#{name}' header is set to #{value.inspect}" do
+ assert_header(name, value)
+ end
+ end
+
+end
+
+class ::ApplicationController < ActionController::Base2
+end
+
+class SimpleRouteCase < Rack::TestCase
+ setup do
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ end
+ end
+end \ No newline at end of file