diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-05-29 16:06:21 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-05-29 16:06:21 -0500 |
commit | 69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3 (patch) | |
tree | 044c2131cc87d21ee54027511aae2b7f2d2ae26a /actionpack/test/new_base/render_template_test.rb | |
parent | 5f3f100ce2d689480da85abc88e5e940cf90189e (diff) | |
parent | 5ec2c7dc29b36d85b2658465b8a979deb0529d7e (diff) | |
download | rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.tar.gz rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.tar.bz2 rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.zip |
Merge branch 'master' into active_model
Conflicts:
activemodel/lib/active_model/core.rb
activemodel/test/cases/state_machine/event_test.rb
activemodel/test/cases/state_machine/state_transition_test.rb
activerecord/lib/active_record/validations.rb
activerecord/test/cases/validations/i18n_validation_test.rb
activeresource/lib/active_resource.rb
activeresource/test/abstract_unit.rb
Diffstat (limited to 'actionpack/test/new_base/render_template_test.rb')
-rw-r--r-- | actionpack/test/new_base/render_template_test.rb | 211 |
1 files changed, 124 insertions, 87 deletions
diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb index c6c0269b40..face5b7571 100644 --- a/actionpack/test/new_base/render_template_test.rb +++ b/actionpack/test/new_base/render_template_test.rb @@ -1,133 +1,170 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") -module HappyPath - - class RenderTemplateWithoutLayoutController < ActionController::Base2 - - self.view_paths = [ActionView::FixtureTemplate::FixturePath.new( - "test/basic.html.erb" => "Hello from basic.html.erb", - "shared.html.erb" => "Elastica" +module RenderTemplate + class WithoutLayoutController < ActionController::Base + + self.view_paths = [ActionView::Template::FixturePath.new( + "test/basic.html.erb" => "Hello from basic.html.erb", + "shared.html.erb" => "Elastica", + "locals.html.erb" => "The secret is <%= secret %>", + "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend" )] - def render_hello_world + def index render :template => "test/basic" end - - def render_hello_world_with_forward_slash - render :template => "/test/basic" + + def index_without_key + render "test/basic" end - def render_template_in_top_directory + def in_top_directory render :template => 'shared' end - def render_template_in_top_directory_with_slash + def in_top_directory_with_slash render :template => '/shared' end - end - - class TestTemplateRenderWithoutLayout < SimpleRouteCase - describe "rendering a normal template with full path without layout" - get "/happy_path/render_template_without_layout/render_hello_world" - assert_body "Hello from basic.html.erb" - assert_status 200 - end - - class TestTemplateRenderWithForwardSlash < SimpleRouteCase - describe "rendering a normal template with full path starting with a leading slash" + def in_top_directory_with_slash_without_key + render '/shared' + end + + def with_locals + render :template => "locals", :locals => { :secret => 'area51' } + end - get "/happy_path/render_template_without_layout/render_hello_world_with_forward_slash" - assert_body "Hello from basic.html.erb" - assert_status 200 + def builder_template + render :template => "xml_template" + end end - class TestTemplateRenderInTopDirectory < SimpleRouteCase - describe "rendering a template not in a subdirectory" + class TestWithoutLayout < SimpleRouteCase + testing RenderTemplate::WithoutLayoutController - get "/happy_path/render_template_without_layout/render_template_in_top_directory" - assert_body "Elastica" - assert_status 200 - end - - class TestTemplateRenderInTopDirectoryWithSlash < SimpleRouteCase - describe "rendering a template not in a subdirectory with a leading slash" + test "rendering a normal template with full path without layout" do + get :index + assert_response "Hello from basic.html.erb" + end - get "/happy_path/render_template_without_layout/render_template_in_top_directory_with_slash" - assert_body "Elastica" - assert_status 200 - end + test "rendering a normal template with full path without layout without key" do + get :index_without_key + assert_response "Hello from basic.html.erb" + end + + test "rendering a template not in a subdirectory" do + get :in_top_directory + assert_response "Elastica" + end + + test "rendering a template not in a subdirectory with a leading slash" do + get :in_top_directory_with_slash + assert_response "Elastica" + end + + test "rendering a template not in a subdirectory with a leading slash without key" do + get :in_top_directory_with_slash_without_key + assert_response "Elastica" + end + + test "rendering a template with local variables" do + get :with_locals + assert_response "The secret is area51" + end - class RenderTemplateWithLayoutController < ::ApplicationController + test "rendering a builder template" do + get :builder_template + assert_response "<html>\n <p>Hello</p>\n</html>\n" + end + end - self.view_paths = [ActionView::FixtureTemplate::FixturePath.new( + class WithLayoutController < ::ApplicationController + self.view_paths = [ActionView::Template::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 + def index render :template => "test/basic" end - def render_hello_world_with_layout + def with_layout render :template => "test/basic", :layout => true end - def render_hello_world_with_layout_false + def with_layout_false render :template => "test/basic", :layout => false end - def render_hello_world_with_layout_nil + def with_layout_nil render :template => "test/basic", :layout => nil end - def render_hello_world_with_custom_layout + def 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 + class TestWithLayout < SimpleRouteCase + describe "Rendering with :template using implicit or explicit layout" + + test "rendering with implicit layout" do + get "/render_template/with_layout" + + assert_body "Hello from basic.html.erb, I'm here!" + assert_status 200 + end + + test "rendering with layout => :true" do + get "/render_template/with_layout/with_layout" + + assert_body "Hello from basic.html.erb, I'm here!" + assert_status 200 + end + + test "rendering with layout => :false" do + get "/render_template/with_layout/with_layout_false" + + assert_body "Hello from basic.html.erb" + assert_status 200 + end + + test "rendering with layout => :nil" do + get "/render_template/with_layout/with_layout_nil" + + assert_body "Hello from basic.html.erb" + assert_status 200 + end + + test "rendering layout => 'greetings'" do + get "/render_template/with_layout/with_custom_layout" + + assert_body "Hello from basic.html.erb, I wish thee well." + assert_status 200 + end end - - + module Compatibility + class WithoutLayoutController < ActionController::Base + self.view_paths = [ActionView::Template::FixturePath.new( + "test/basic.html.erb" => "Hello from basic.html.erb", + "shared.html.erb" => "Elastica" + )] + + def with_forward_slash + render :template => "/test/basic" + end + end + + class TestTemplateRenderWithForwardSlash < SimpleRouteCase + test "rendering a normal template with full path starting with a leading slash" do + get "/render_template/compatibility/without_layout/with_forward_slash" + + assert_body "Hello from basic.html.erb" + assert_status 200 + end + end + end end
\ No newline at end of file |