aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-11-11 11:08:17 -0200
committerJosé Valim <jose.valim@gmail.com>2010-11-11 16:22:39 +0100
commit7846fb79e1296986c41250bfea2e115e7683fa61 (patch)
tree11369d0e7bb9376a270d762f02a99b66a78e50b2
parent50c7aab996baafdfee4b1e4b2ca4673ee76bb19a (diff)
downloadrails-7846fb79e1296986c41250bfea2e115e7683fa61.tar.gz
rails-7846fb79e1296986c41250bfea2e115e7683fa61.tar.bz2
rails-7846fb79e1296986c41250bfea2e115e7683fa61.zip
Fix render partial with layout and no block
When using a render :partial with :layout call, without giving a block, if the given :partial had another render :partial call, the layout was not being rendered. This commit fixes this context by storing variables before rendering the partial, so they are not overrided in any successive call to render partials down the path. All ActionPack tests are ok.
-rw-r--r--actionpack/test/fixtures/test/_partial_with_partial.erb2
-rw-r--r--actionpack/test/template/render_test.rb10
2 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/test/fixtures/test/_partial_with_partial.erb b/actionpack/test/fixtures/test/_partial_with_partial.erb
new file mode 100644
index 0000000000..ee0d5037b6
--- /dev/null
+++ b/actionpack/test/fixtures/test/_partial_with_partial.erb
@@ -0,0 +1,2 @@
+<%= render 'test/partial' %>
+partial with partial
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 7736b936a1..08d50257d4 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -267,6 +267,16 @@ module RenderTestCases
@view.render(:layout => "layouts/partial_and_yield") { "Content from block!" }
end
+ def test_render_partial_and_layout_without_block_with_locals
+ assert_equal %(Before (Foo!)\npartial html\nAfter),
+ @view.render(:partial => 'test/partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'})
+ end
+
+ def test_render_partial_and_layout_without_block_with_locals_and_rendering_another_partial
+ assert_equal %(Before (Foo!)\npartial html\npartial with partial\n\nAfter),
+ @view.render(:partial => 'test/partial_with_partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'})
+ end
+
def test_render_with_nested_layout
assert_equal %(<title>title</title>\n\n<div id="column">column</div>\n<div id="content">content</div>\n),
@view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield")