Permalink
Browse files

Use the right format when a partial is missing.

Closes #5025
  • Loading branch information...
spastorino committed Feb 20, 2012
1 parent 5e3b54d commit 70fd692c1eada44027f9581f84461ca87abba8c6
@@ -163,6 +163,7 @@ def refresh(view)
pieces = @virtual_path.split("/")
name = pieces.pop
partial = !!name.sub!(/^_/, "")
+ lookup.formats = @formats

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Feb 20, 2012

Contributor

We should have an ensure block that sets lookup.formats to its original value.

@josevalim

josevalim Feb 20, 2012

Contributor

We should have an ensure block that sets lookup.formats to its original value.

This comment has been minimized.

Show comment Hide comment
@spastorino

spastorino Feb 21, 2012

Member

Fixed 92a7296

lookup.disable_cache do
lookup.find_template(name, [ pieces.join('/') ], partial, @locals)
end
@@ -0,0 +1 @@
+<%= render :partial => 'missing', :formats => [:json] %>
@@ -51,6 +51,13 @@ def test_render_template_with_format
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)

0 comments on commit 70fd692

Please sign in to comment.