mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix issue with rendering partials and then yielding inside a render layout call
The given block was never being executed when another render :partial call existed before the yield call, due to the block being overriden. This commit also adds some more tests to render with :layout option.
This commit is contained in:
parent
920660b19c
commit
50c7aab996
5 changed files with 26 additions and 0 deletions
2
actionpack/test/fixtures/layouts/_partial_and_yield.erb
vendored
Normal file
2
actionpack/test/fixtures/layouts/_partial_and_yield.erb
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<%= render :partial => 'test/partial' %>
|
||||||
|
<%= yield %>
|
1
actionpack/test/fixtures/layouts/_yield_only.erb
vendored
Normal file
1
actionpack/test/fixtures/layouts/_yield_only.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= yield %>
|
1
actionpack/test/fixtures/layouts/_yield_with_params.erb
vendored
Normal file
1
actionpack/test/fixtures/layouts/_yield_with_params.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= yield 'Yield!' %>
|
2
actionpack/test/fixtures/layouts/yield_with_render_partial_inside.erb
vendored
Normal file
2
actionpack/test/fixtures/layouts/yield_with_render_partial_inside.erb
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<%= render :partial => 'test/partial' %>
|
||||||
|
<%= yield %>
|
|
@ -247,6 +247,26 @@ module RenderTestCases
|
||||||
@view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_inline_inside")
|
@view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_inline_inside")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_render_with_layout_which_renders_another_partial
|
||||||
|
assert_equal %(partial html\nHello world!\n),
|
||||||
|
@view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_partial_inside")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_render_layout_with_block_and_yield
|
||||||
|
assert_equal %(Content from block!\n),
|
||||||
|
@view.render(:layout => "layouts/yield_only") { "Content from block!" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_render_layout_with_block_and_yield_with_params
|
||||||
|
assert_equal %(Yield! Content from block!\n),
|
||||||
|
@view.render(:layout => "layouts/yield_with_params") { |param| "#{param} Content from block!" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_render_layout_with_block_which_renders_another_partial_and_yields
|
||||||
|
assert_equal %(partial html\nContent from block!\n),
|
||||||
|
@view.render(:layout => "layouts/partial_and_yield") { "Content from block!" }
|
||||||
|
end
|
||||||
|
|
||||||
def test_render_with_nested_layout
|
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),
|
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")
|
@view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield")
|
||||||
|
|
Loading…
Reference in a new issue