diff options
Diffstat (limited to 'actionpack/test/new_base/render_template_test.rb')
-rw-r--r-- | actionpack/test/new_base/render_template_test.rb | 91 |
1 files changed, 84 insertions, 7 deletions
diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb index 758a206dbb..273e26b83f 100644 --- a/actionpack/test/new_base/render_template_test.rb +++ b/actionpack/test/new_base/render_template_test.rb @@ -2,7 +2,12 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module HappyPath - class RenderTemplateController < ActionController::Base2 + 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" @@ -21,10 +26,10 @@ module HappyPath end end - class TestTemplateRender < SimpleRouteCase - describe "rendering a normal template with full path" + class TestTemplateRenderWithoutLayout < SimpleRouteCase + describe "rendering a normal template with full path without layout" - get "/happy_path/render_template/render_hello_world" + get "/happy_path/render_template_without_layout/render_hello_world" assert_body "Hello from basic.html.erb" assert_status 200 end @@ -32,7 +37,7 @@ module HappyPath class TestTemplateRenderWithForwardSlash < SimpleRouteCase describe "rendering a normal template with full path starting with a leading slash" - get "/happy_path/render_template/render_hello_world_with_forward_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 @@ -40,7 +45,7 @@ module HappyPath class TestTemplateRenderInTopDirectory < SimpleRouteCase describe "rendering a template not in a subdirectory" - get "/happy_path/render_template/render_template_in_top_directory" + get "/happy_path/render_template_without_layout/render_template_in_top_directory" assert_body "Elastica" assert_status 200 end @@ -48,9 +53,81 @@ module HappyPath class TestTemplateRenderInTopDirectoryWithSlash < SimpleRouteCase describe "rendering a template not in a subdirectory with a leading slash" - get "/happy_path/render_template/render_template_in_top_directory_with_slash" + get "/happy_path/render_template_without_layout/render_template_in_top_directory_with_slash" assert_body "Elastica" assert_status 200 end + + class RenderTemplateWithLayoutController < ActionController::Base2 + + 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 |