From ab17ecfe5d97d5026d67688ddefe11a458701076 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 20 Mar 2009 18:38:03 -0700 Subject: Finished implementing :layout for most of the render options --- actionpack/test/new_base/render_text_test.rb | 38 ++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'actionpack/test/new_base/render_text_test.rb') diff --git a/actionpack/test/new_base/render_text_test.rb b/actionpack/test/new_base/render_text_test.rb index f91e6bd644..b80a9b4a79 100644 --- a/actionpack/test/new_base/render_text_test.rb +++ b/actionpack/test/new_base/render_text_test.rb @@ -2,7 +2,15 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module HappyPath - class RenderTextController < ActionController::Base2 + class RenderTextWithoutLayoutsController < ActionController::Base2 + self.view_paths = [ActionView::FixtureTemplate::FixturePath.new] + + def render_hello_world + render :text => "hello david" + end + end + + class RenderTextWithLayoutsController < ActionController::Base2 self.view_paths = [ActionView::FixtureTemplate::FixturePath.new( "layouts/application.html.erb" => "<%= yield %>, I'm here!", "layouts/greetings.html.erb" => "<%= yield %>, I wish thee well." @@ -49,10 +57,18 @@ module HappyPath end end - class TestSimpleTextRender < SimpleRouteCase + 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/render_hello_world" + get "/happy_path/render_text_with_layouts/render_hello_world" assert_body "hello david" assert_status 200 end @@ -60,7 +76,7 @@ module HappyPath class TestTextRenderWithStatus < SimpleRouteCase describe "Rendering text, while also providing a custom status code" - get "/happy_path/render_text/render_custom_code" + get "/happy_path/render_text_with_layouts/render_custom_code" assert_body "hello world" assert_status 404 end @@ -68,7 +84,7 @@ module HappyPath class TestTextRenderWithNil < SimpleRouteCase describe "Rendering text with nil returns a single space character" - get "/happy_path/render_text/render_text_with_nil" + get "/happy_path/render_text_with_layouts/render_text_with_nil" assert_body " " assert_status 200 end @@ -76,7 +92,7 @@ module HappyPath 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/render_text_with_nil_and_status" + get "/happy_path/render_text_with_layouts/render_text_with_nil_and_status" assert_body " " assert_status 403 end @@ -84,7 +100,7 @@ module HappyPath class TestTextRenderWithFalse < SimpleRouteCase describe "Rendering text with false returns the string 'false'" - get "/happy_path/render_text/render_text_with_false" + get "/happy_path/render_text_with_layouts/render_text_with_false" assert_body "false" assert_status 200 end @@ -92,7 +108,7 @@ module HappyPath class TestTextRenderWithLayoutTrue < SimpleRouteCase describe "Rendering text with :layout => true" - get "/happy_path/render_text/render_text_with_layout" + get "/happy_path/render_text_with_layouts/render_text_with_layout" assert_body "hello world, I'm here!" assert_status 200 end @@ -100,7 +116,7 @@ module HappyPath class TestTextRenderWithCustomLayout < SimpleRouteCase describe "Rendering text with :layout => 'greetings'" - get "/happy_path/render_text/render_text_with_custom_layout" + get "/happy_path/render_text_with_layouts/render_text_with_custom_layout" assert_body "hello world, I wish thee well." assert_status 200 end @@ -108,7 +124,7 @@ module HappyPath class TestTextRenderWithLayoutFalse < SimpleRouteCase describe "Rendering text with :layout => false" - get "/happy_path/render_text/render_text_with_layout_false" + get "/happy_path/render_text_with_layouts/render_text_with_layout_false" assert_body "hello world" assert_status 200 end @@ -116,7 +132,7 @@ module HappyPath class TestTextRenderWithLayoutNil < SimpleRouteCase describe "Rendering text with :layout => nil" - get "/happy_path/render_text/render_text_with_layout_nil" + get "/happy_path/render_text_with_layouts/render_text_with_layout_nil" assert_body "hello world" assert_status 200 end -- cgit v1.2.3