aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/new_base/render_template_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-04-22 15:26:03 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-04-22 15:26:03 +0100
commit5f3f100ce2d689480da85abc88e5e940cf90189e (patch)
tree15c1a05a5308a9eea56d7f0889ac46d9cac5b57c /actionpack/test/new_base/render_template_test.rb
parentd758d996d1b66e2a65640f79f01ce2ac674d7ed5 (diff)
parentca49299434bc764b667cd86846d892e91a150ef3 (diff)
downloadrails-5f3f100ce2d689480da85abc88e5e940cf90189e.tar.gz
rails-5f3f100ce2d689480da85abc88e5e940cf90189e.tar.bz2
rails-5f3f100ce2d689480da85abc88e5e940cf90189e.zip
Merge branch 'master' into active_model
Conflicts: activeresource/lib/active_resource/validations.rb
Diffstat (limited to 'actionpack/test/new_base/render_template_test.rb')
-rw-r--r--actionpack/test/new_base/render_template_test.rb133
1 files changed, 133 insertions, 0 deletions
diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb
new file mode 100644
index 0000000000..c6c0269b40
--- /dev/null
+++ b/actionpack/test/new_base/render_template_test.rb
@@ -0,0 +1,133 @@
+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"
+ )]
+
+ def render_hello_world
+ render :template => "test/basic"
+ end
+
+ def render_hello_world_with_forward_slash
+ render :template => "/test/basic"
+ end
+
+ def render_template_in_top_directory
+ render :template => 'shared'
+ end
+
+ def render_template_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"
+
+ get "/happy_path/render_template_without_layout/render_hello_world_with_forward_slash"
+ assert_body "Hello from basic.html.erb"
+ assert_status 200
+ end
+
+ class TestTemplateRenderInTopDirectory < SimpleRouteCase
+ describe "rendering a template not in a subdirectory"
+
+ 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"
+
+ get "/happy_path/render_template_without_layout/render_template_in_top_directory_with_slash"
+ assert_body "Elastica"
+ assert_status 200
+ end
+
+ class RenderTemplateWithLayoutController < ::ApplicationController
+
+ 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