Use the right format when a partial is missing.

Closes #5025
This commit is contained in:
Santiago Pastorino
2012-02-20 16:48:43 -02:00
parent 8c870f11f2
commit 8b86259bea
3 changed files with 9 additions and 0 deletions

View File

@@ -164,6 +164,7 @@ module ActionView
pieces = @virtual_path.split("/")
name = pieces.pop
partial = !!name.sub!(/^_/, "")
lookup.formats = @formats
lookup.disable_cache do
lookup.find_template(name, [ pieces.join('/') ], partial, @locals)
end

View File

@@ -0,0 +1 @@
<%= render :partial => 'missing', :formats => [:json] %>

View File

@@ -51,6 +51,13 @@ module RenderTestCases
assert_match "<error>No Comment</error>", @view.render(:template => "comments/empty", :formats => [:xml])
end
def test_render_template_with_a_missing_partial_of_another_format
assert_raise ActionView::Template::Error, "Missing partial /missing with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder]}" do
@view.lookup_context.freeze_formats([:html])
@view.render(:template => "with_format", :formats => [:json])
end
end
def test_render_file_with_locale
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => [:de])
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => :de)