From d67e03871eabb912434dafac3eeb8e6ea7c5585f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 25 Dec 2008 22:11:06 +0000 Subject: Make ActionController#render(string) work as a shortcut for render :template => string. [#1435] Examples: # Instead of render(:template => 'controller/action') render('controller/action') Note : Argument must not begin with a '/', but have at least one '/' --- actionpack/test/controller/render_test.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index f2393e695a..ce9756a060 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -202,6 +202,11 @@ class TestController < ActionController::Base render :template => "test/hello" end + def render_xml_hello_as_string_template + @name = "David" + render "test/hello" + end + def render_xml_with_custom_content_type render :xml => "", :content_type => "application/atomsvc+xml" end @@ -332,6 +337,10 @@ class TestController < ActionController::Base render :template => "test/hello_world" end + def render_with_explicit_string_template + render "test/hello_world" + end + def render_with_explicit_template_with_locals render :template => "test/render_file_with_locals", :locals => { :secret => 'area51' } end @@ -654,6 +663,7 @@ class TestController < ActionController::Base "accessing_params_in_template", "accessing_params_in_template_with_layout", "render_with_explicit_template", + "render_with_explicit_string_template", "render_js_with_explicit_template", "render_js_with_explicit_action_template", "delete_with_js", "update_page", "update_page_with_instance_variables" @@ -888,6 +898,12 @@ class RenderTest < ActionController::TestCase assert_equal "application/xml", @response.content_type end + def test_render_xml_as_string_template + get :render_xml_hello_as_string_template + assert_equal "\n

Hello David

\n

This is grand!

\n\n", @response.body + assert_equal "application/xml", @response.content_type + end + def test_render_xml_with_default get :greeting assert_equal "

This is grand!

\n", @response.body @@ -1073,6 +1089,11 @@ class RenderTest < ActionController::TestCase assert_response :success end + def test_render_with_explicit_string_template + get :render_with_explicit_string_template + assert_equal "Hello world!", @response.body + end + def test_double_render assert_raises(ActionController::DoubleRenderError) { get :double_render } end -- cgit v1.2.3