Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure :layout => false is always used when rendering inside a layout

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1970 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit a3469cadadfd770ad9029f651f3a51560bbd3045 1 parent 3d4a323
@jamis jamis authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Make sure :layout => false is always used when rendering inside a layout
+
* Use raise instead of assert_not_nil in Test::Unit::TestCase#process to ensure that the test variables (controller, request, response) have been set
* Make sure assigns are built for every request when testing #1866
View
3  actionpack/lib/action_controller/layout.rb
@@ -208,6 +208,7 @@ def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layo
template_with_options = options.is_a?(Hash)
if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options, deprecated_layout))
+ options = options.merge :layout => false if template_with_options
logger.info("Rendering #{options} within #{layout}") if logger
if template_with_options
@@ -266,4 +267,4 @@ def action_has_layout?
end
end
end
-end
+end
View
11 actionpack/test/controller/new_render_test.rb
@@ -59,6 +59,10 @@ def layout_test_with_different_layout
def rendering_without_layout
render :action => "hello_world", :layout => false
end
+
+ def layout_overriding_layout
+ render :action => "hello_world", :layout => "standard"
+ end
def rendering_nothing_on_layout
render :nothing => true
@@ -154,7 +158,7 @@ def determine_layout
"layouts/standard"
when "builder_layout_test"
"layouts/builder"
- when "action_talk_to_layout"
+ when "action_talk_to_layout", "layout_overriding_layout"
"layouts/talk_from_action"
end
end
@@ -261,6 +265,11 @@ def test_rendering_without_layout
assert_equal "Hello world!", @response.body
end
+ def test_layout_overriding_layout
+ get :layout_overriding_layout
+ assert_no_match %r{<title>}, @response.body
+ end
+
def test_rendering_nothing_on_layout
get :rendering_nothing_on_layout
assert_equal " ", @response.body
Please sign in to comment.
Something went wrong with that request. Please try again.