1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

render(:template) applies a layout by default. render("foo/bar") works with a layout again.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1424 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2005-06-15 13:20:17 +00:00
parent 280c224b43
commit 14c378cc7f
4 changed files with 16 additions and 18 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* render("foo/bar") works with a layout again
* Fixed double-singularization on scaffolded pagination call (Address would be turned into Addres) #1216, #1404 [nilsga]
* Removed the require hack used by functional testing to work around an earlier bug in rake.
@ -24,7 +26,7 @@
* Make sure the benchmarking render method always returns the output of the render.
* render(:action) and render() are the only two calls that default to using a layout. All other render calls assume :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action.
* render(:action), render(:template) and render() are the only three calls that default to using a layout. All other render calls assume :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action.
* verify with :redirect_to won't redirect if a redirect or render has already been performed #1350

View file

@ -219,8 +219,8 @@ module ActionController #:nodoc:
private
def render_with_a_layout_options(options)
return options unless options.is_a?(Hash)
if options.values_at(:text, :file, :template, :inline, :partial, :nothing).compact.empty?
return { :template => options } unless options.is_a?(Hash)
if options.values_at(:text, :file, :inline, :partial, :nothing).compact.empty?
options
else
{ :layout => false }.merge(options)

View file

@ -94,6 +94,10 @@ class NewRenderTestController < ActionController::Base
render :inline => "Hello: <%= params[:name] %>", :layout => nil
end
def render_with_explicit_template
render "test/hello_world"
end
def rescue_action(e) raise end
private
@ -103,7 +107,8 @@ class NewRenderTestController < ActionController::Base
"rendering_nothing_on_layout", "render_text_hello_world",
"partial_only", "partial_only_with_layout",
"accessing_params_in_template",
"accessing_params_in_template_with_layout"
"accessing_params_in_template_with_layout",
"render_with_explicit_template"
"layouts/standard"
when "builder_layout_test"
"layouts/builder"
@ -249,4 +254,9 @@ class NewRenderTest < Test::Unit::TestCase
get :accessing_params_in_template_with_layout, :name => "David"
assert_equal "<html>Hello: David</html>", @response.body
end
def test_render_with_explicit_template
get :render_with_explicit_template
assert_response :success
end
end

View file

@ -88,20 +88,6 @@ end
TestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
Fun::GamesController.template_root = File.dirname(__FILE__) + "/../fixtures/"
class TestLayoutController < ActionController::Base
layout "layouts/standard"
def hello_world
end
def hello_world_outside_layout
end
def rescue_action(e)
raise unless ActionController::MissingTemplate === e
end
end
class RenderTest < Test::Unit::TestCase
def setup
@request = ActionController::TestRequest.new