From 890321e51e0c51f61f9198d247727e98f7485899 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 19 Mar 2009 15:45:48 -0700 Subject: Get very basic layouts working. * Required small architecture change --- actionpack/test/new_base/render_action_test.rb | 23 ++++++++++++++++++++++ actionpack/test/new_base/test_helper.rb | 1 + .../render_action_with_layout/hello_world.html.erb | 1 + .../views/with_layout/layouts/application.html.erb | 1 + 4 files changed, 26 insertions(+) create mode 100644 actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb create mode 100644 actionpack/test/new_base/views/with_layout/layouts/application.html.erb (limited to 'actionpack/test/new_base') diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb index b6e98f82aa..99482cd4a1 100644 --- a/actionpack/test/new_base/render_action_test.rb +++ b/actionpack/test/new_base/render_action_test.rb @@ -2,6 +2,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module HappyPath + # This has no layout and it works class RenderActionController < ActionController::Base2 def render_action_hello_world @@ -71,5 +72,27 @@ module HappyPath assert_body "Hello world!" assert_status 200 end + + # # ==== Render actions with layouts ==== + + class RenderActionWithLayoutController < ActionController::Base2 + # Set the view path to an application view structure with layouts + self.view_paths = [File.join(File.dirname(__FILE__), 'views', 'with_layout')] + + def hello_world + render :action => "hello_world" + end + end + + class TestRenderActionWithLayout < 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 "/happy_path/render_action_with_layout/hello_world" + assert_body "OHAI Hello World! KTHXBAI" + assert_status 200 + end end \ No newline at end of file diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb index 7a1adc3755..af790aa5dd 100644 --- a/actionpack/test/new_base/test_helper.rb +++ b/actionpack/test/new_base/test_helper.rb @@ -33,6 +33,7 @@ module ActionController include ActionController::HideActions include ActionController::UrlFor include ActionController::Renderer + include ActionController::Layouts def self.inherited(klass) @subclasses ||= [] diff --git a/actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb b/actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb new file mode 100644 index 0000000000..c57eff55eb --- /dev/null +++ b/actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_layout/layouts/application.html.erb b/actionpack/test/new_base/views/with_layout/layouts/application.html.erb new file mode 100644 index 0000000000..25f839fded --- /dev/null +++ b/actionpack/test/new_base/views/with_layout/layouts/application.html.erb @@ -0,0 +1 @@ +OHAI <%= yield %> KTHXBAI \ No newline at end of file -- cgit v1.2.3