aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-08-05 20:51:03 +0000
committerJamis Buck <jamis@37signals.com>2005-08-05 20:51:03 +0000
commita3469cadadfd770ad9029f651f3a51560bbd3045 (patch)
tree3ba4a3b7b046ec8964d2a3dbed77563c15413bce /actionpack
parent3d4a32377651a13575ce6da84875af764fdbe339 (diff)
downloadrails-a3469cadadfd770ad9029f651f3a51560bbd3045.tar.gz
rails-a3469cadadfd770ad9029f651f3a51560bbd3045.tar.bz2
rails-a3469cadadfd770ad9029f651f3a51560bbd3045.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/layout.rb3
-rw-r--r--actionpack/test/controller/new_render_test.rb11
3 files changed, 14 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 5d3765aaba..b860ce3986 100644
--- a/actionpack/CHANGELOG
+++ b/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
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index 4247e8a1cf..c7f3420a6e 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -208,6 +208,7 @@ module ActionController #:nodoc:
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 @@ module ActionController #:nodoc:
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 77e9d5be26..1e077bb902 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -59,6 +59,10 @@ class NewRenderTestController < ActionController::Base
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 @@ class NewRenderTestController < ActionController::Base
"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 @@ class NewRenderTest < Test::Unit::TestCase
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