Browse files

Restore lookup formats to the previous value after searching for the …

…failing view
  • Loading branch information...
1 parent b122968 commit 4eff6bc6dfeea3eed5d92af66bd73e6a2cb9b09f @spastorino spastorino committed Feb 21, 2012
Showing with 5 additions and 2 deletions.
  1. +3 −1 actionpack/lib/action_view/template.rb
  2. +2 −1 actionpack/test/template/render_test.rb
View
4 actionpack/lib/action_view/template.rb
@@ -164,10 +164,12 @@ def refresh(view)
pieces = @virtual_path.split("/")
name = pieces.pop
partial = !!name.sub!(/^_/, "")
- lookup.formats = @formats
+ previous_formats, lookup.formats = lookup.formats, @formats
lookup.disable_cache do
lookup.find_template(name, [ pieces.join('/') ], partial, @locals)
end
+ ensure
+ lookup.formats = previous_formats
end
def inspect
View
3 actionpack/test/template/render_test.rb
@@ -52,10 +52,11 @@ def test_render_template_with_format
end
def test_render_template_with_a_missing_partial_of_another_format
+ @view.lookup_context.freeze_formats([:html])
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
+ assert_equal [:html], @view.lookup_context.formats
end
def test_render_file_with_locale

0 comments on commit 4eff6bc

Please sign in to comment.