Permalink
Browse files

Merge pull request #8402 from senny/8376_descriptive_error_message_fo…

…r_partial_layout_true

More descriptive error when rendering a partial with `:layout => true`
Conflicts:
	actionpack/CHANGELOG.md
	actionpack/lib/action_view/renderer/partial_renderer.rb
  • Loading branch information...
1 parent a50ab21 commit eaa0d0b7744327151d44d0a147fbb70c72678d35 @rafaelfranca rafaelfranca committed Dec 2, 2012
View
@@ -1,5 +1,15 @@
## Rails 3.2.10 (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*
+
* Accept symbols as #send_data :disposition value. [Backport #8329] *Elia Schito*
* Add i18n scope to distance_of_time_in_words. [Backport #7997] *Steve Klabnik*
@@ -256,7 +256,7 @@ def render_partial
object, as = @object, @variable
if !block && (layout = @options[:layout])
- layout = find_template(layout)
+ layout = find_template(layout.to_s)
end
object ||= locals[as]
@@ -336,7 +336,7 @@ def test_render_inline_with_locals_and_compilable_custom_type
ActionView::Template.register_template_handler :foo, CustomHandler
assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
end
-
+
def test_render_knows_about_types_registered_when_extensions_are_checked_earlier_in_initialization
ActionView::Template::Handlers.extensions
ActionView::Template.register_template_handler :foo, CustomHandler
@@ -406,6 +406,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")

0 comments on commit eaa0d0b

Please sign in to comment.