aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract_controller
diff options
context:
space:
mode:
authorYehuda Katz and Carl Lerche <wycats@gmail.com>2009-03-23 15:45:01 -0700
committerYehuda Katz and Carl Lerche <wycats@gmail.com>2009-03-23 15:45:01 -0700
commita501638e9dcf55e45613637c52e4169b6324f285 (patch)
treeafc99eff992a16b6b328563eb9db8cf707686cf2 /actionpack/test/abstract_controller
parent34f058e082754bb726a4753fa26e8e8c082702c0 (diff)
downloadrails-a501638e9dcf55e45613637c52e4169b6324f285.tar.gz
rails-a501638e9dcf55e45613637c52e4169b6324f285.tar.bz2
rails-a501638e9dcf55e45613637c52e4169b6324f285.zip
Checkpoint
Diffstat (limited to 'actionpack/test/abstract_controller')
-rw-r--r--actionpack/test/abstract_controller/layouts_test.rb64
-rw-r--r--actionpack/test/abstract_controller/test_helper.rb2
2 files changed, 66 insertions, 0 deletions
diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract_controller/layouts_test.rb
new file mode 100644
index 0000000000..35329eea83
--- /dev/null
+++ b/actionpack/test/abstract_controller/layouts_test.rb
@@ -0,0 +1,64 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+module AbstractControllerTests
+ module Layouts
+
+ # Base controller for these tests
+ class Base < AbstractController::Base
+ include AbstractController::Renderer
+ include AbstractController::Layouts
+
+ self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(
+ "layouts/hello.html.erb" => "With String <%= yield %>"
+ )]
+
+ def render_to_string(options)
+ options[:_layout] = _default_layout
+ super
+ end
+ end
+
+ class Blank < Base
+ self.view_paths = []
+
+ def index
+ render :_template => ActionView::TextTemplate.new("Hello blank!")
+ end
+ end
+
+ class WithString < Base
+ layout "hello"
+
+ def index
+ render :_template => ActionView::TextTemplate.new("Hello string!")
+ end
+ end
+
+ class WithMissingLayout < Base
+ layout "missing"
+
+ def index
+ render :_template => ActionView::TextTemplate.new("Hello missing!")
+ end
+ end
+
+
+ class TestBase < ActiveSupport::TestCase
+ test "when no layout is specified, and no default is available, render without a layout" do
+ result = Blank.process(:index)
+ assert_equal "Hello blank!", result.response_obj[:body]
+ end
+
+ test "when layout is specified as a string, render with that layout" do
+ result = Blank.process(:index)
+ assert_equal "With String Hello string!", result.response_obj[:body]
+ end
+
+ test "when layout is specified as a string, but the layout is missing, raise an exception" do
+ assert_raises(ActionView::MissingTemplate) { WithMissingLayout.process(:index) }
+ end
+ end
+
+
+ end
+end \ No newline at end of file
diff --git a/actionpack/test/abstract_controller/test_helper.rb b/actionpack/test/abstract_controller/test_helper.rb
index 5fbd3a9e23..b9248c6bbd 100644
--- a/actionpack/test/abstract_controller/test_helper.rb
+++ b/actionpack/test/abstract_controller/test_helper.rb
@@ -1,11 +1,13 @@
$:.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'