aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorYehuda Katz and Carl Lerche <wycats@gmail.com>2009-04-07 17:57:20 -0700
committerYehuda Katz and Carl Lerche <wycats@gmail.com>2009-04-07 17:57:20 -0700
commit3cecbc21e37f772a72917f80c53a7645f81d94c5 (patch)
treefbdb4e9a6934e066ecc14e06b7f76202d54e29b1 /actionpack/test
parent95c9718118bc0342ddb320f23b5e0a17fb12b7ad (diff)
downloadrails-3cecbc21e37f772a72917f80c53a7645f81d94c5.tar.gz
rails-3cecbc21e37f772a72917f80c53a7645f81d94c5.tar.bz2
rails-3cecbc21e37f772a72917f80c53a7645f81d94c5.zip
Get Base2 layouts to work :)
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_controller/layouts_test.rb13
-rw-r--r--actionpack/test/new_base/render_action_test.rb12
-rw-r--r--actionpack/test/new_base/render_layout_test.rb45
-rw-r--r--actionpack/test/new_base/render_template_test.rb4
-rw-r--r--actionpack/test/new_base/test_helper.rb12
5 files changed, 77 insertions, 9 deletions
diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract_controller/layouts_test.rb
index 541d126958..5dd68ec28e 100644
--- a/actionpack/test/abstract_controller/layouts_test.rb
+++ b/actionpack/test/abstract_controller/layouts_test.rb
@@ -144,7 +144,6 @@ module AbstractControllerTests
AbstractController::Base.subclasses.each do |klass|
klass = klass.constantize
next unless klass < AbstractController::Layouts
- p klass
klass.class_eval do
_write_layout_method
end
@@ -217,7 +216,17 @@ module AbstractControllerTests
"parent has specified a layout, use the child controller layout" do
result = WithChildOfImplied.process(:index)
assert_equal "With Implied Hello string!", result.response_obj[:body]
- end
+ end
+
+ test "raises an exception when specifying layout true" do
+ assert_raises ArgumentError do
+ Object.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
+ class ::BadOmgFailLolLayout < AbstractControllerTests::Layouts::Base
+ layout true
+ end
+ RUBY_EVAL
+ end
+ end
end
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
index bbc8939af4..2bfb374a31 100644
--- a/actionpack/test/new_base/render_action_test.rb
+++ b/actionpack/test/new_base/render_action_test.rb
@@ -91,7 +91,9 @@ module RenderAction
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(ActionView::MissingTemplate) { get "/render_action/basic/hello_world_with_layout" }
+ assert_raise(ArgumentError, /no default layout for RenderAction::BasicController in/) do
+ get "/render_action/basic/hello_world_with_layout"
+ end
end
end
@@ -124,13 +126,13 @@ end
module RenderActionWithApplicationLayout
# # ==== Render actions with layouts ====
-
- class BasicController < ActionController::Base2
+
+ 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"
+ "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI",
+ "layouts/greetings.html.erb" => "Greetings <%= yield %> Bai"
)]
def hello_world
diff --git a/actionpack/test/new_base/render_layout_test.rb b/actionpack/test/new_base/render_layout_test.rb
index e69de29bb2..facf67ea85 100644
--- a/actionpack/test/new_base/render_layout_test.rb
+++ 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
index 273e26b83f..c6c0269b40 100644
--- a/actionpack/test/new_base/render_template_test.rb
+++ b/actionpack/test/new_base/render_template_test.rb
@@ -57,8 +57,8 @@ module HappyPath
assert_body "Elastica"
assert_status 200
end
-
- class RenderTemplateWithLayoutController < ActionController::Base2
+
+ class RenderTemplateWithLayoutController < ::ApplicationController
self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb
index 5edd7b4f63..d29449ddc1 100644
--- a/actionpack/test/new_base/test_helper.rb
+++ b/actionpack/test/new_base/test_helper.rb
@@ -69,6 +69,15 @@ class Rack::TestCase < ActiveSupport::TestCase
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
@@ -123,6 +132,9 @@ class Rack::TestCase < ActiveSupport::TestCase
end
+class ::ApplicationController < ActionController::Base2
+end
+
class SimpleRouteCase < Rack::TestCase
setup do
ActionController::Routing::Routes.draw do |map|