From 92a7296a5deb109d054b32d96fa1a74f0859a81b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 21 Feb 2012 14:55:34 -0200 Subject: Restore lookup formats to the previous value after searching for the failing view --- actionpack/lib/action_view/template.rb | 4 +++- actionpack/test/template/render_test.rb | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 644debd49c..630625fb90 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -163,10 +163,12 @@ module ActionView 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 diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index e4ce756bf8..3b461f3529 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -52,10 +52,11 @@ module RenderTestCases 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 -- cgit v1.2.3