提交 ea535261 编写于 作者: R Rafael Mendonça França

Merge pull request #8402 from senny/8376_descriptive_error_message_for_partial_layout_true

More descriptive error when rendering a partial with `:layout => true`
## Rails 4.0.0 (unreleased) ##
* More descriptive error messages when calling `render :partial` with
an invalid `:layout` argument.
#8376
render :partial => 'partial', :layout => true
# results in ActionView::MissingTemplate: Missing partial /true
*Yves Senn*
* Sweepers was extracted from Action Controller as `rails-observers` gem.
*Rafael Mendonça França*
......
......@@ -293,7 +293,7 @@ def render_partial
object, as = @object, @variable
if !block && (layout = @options[:layout])
layout = find_template(layout, @template_keys)
layout = find_template(layout.to_s, @template_keys)
end
object ||= locals[as]
......
......@@ -437,6 +437,11 @@ def test_render_layout_with_a_nested_render_layout_call_using_block_with_render_
@view.render(:partial => 'test/partial_with_layout_block_content', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'})
end
def test_render_partial_with_layout_raises_descriptive_error
e = assert_raises(ActionView::MissingTemplate) { @view.render(partial: 'test/partial', layout: true) }
assert_match "Missing partial /true with", e.message
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", :layout => "layouts/yield")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册