From a480f81291804b2206b5898e83c6d0dea5004c50 Mon Sep 17 00:00:00 2001 From: Eugene Pimenov Date: Sun, 24 Jan 2010 04:54:01 +0300 Subject: [PATCH] do not fail layout lookup when rendering a template with locale in its filename --- actionpack/lib/action_view/template/resolver.rb | 2 +- actionpack/test/abstract/layouts_test.rb | 25 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index c6a1790..049c0f3 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -123,7 +123,7 @@ module ActionView handler = Template.handler_class_for_extension(m[3]) format = Mime[details.last] && details.pop.to_sym - locale = details.last && details.pop.to_sym + locale = details.last && [details.pop.to_sym] return handler, :format => format, :locale => locale, :partial => partial end diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb index df73d94..d68121f 100644 --- a/actionpack/test/abstract/layouts_test.rb +++ b/actionpack/test/abstract/layouts_test.rb @@ -15,7 +15,9 @@ module AbstractControllerTests "layouts/abstract_controller_tests/layouts/with_string_implied_child.erb" => "With Implied <%= yield %>", "layouts/omg.erb" => "OMGHI2U <%= yield %>", - "layouts/with_false_layout.erb" => "False Layout <%= yield %>" + "layouts/with_false_layout.erb" => "False Layout <%= yield %>", + "abstract_controller_tests/layouts/with_locale_in_template/hello_world.da.html.erb" => + "Hey verden" )] end @@ -145,7 +147,15 @@ module AbstractControllerTests render :_template => ActionView::Template::Text.new("Hello nil!") end end - + + class WithLocaleInTemplate < Base + layout "hello" + + def index + render 'hello_world' + end + end + class TestBase < ActiveSupport::TestCase test "when no layout is specified, and no default is available, render without a layout" do controller = Blank.new @@ -259,6 +269,17 @@ module AbstractControllerTests end end end + + test "when template has locale in its filename, do not fail layout lookup" do + controller = WithLocaleInTemplate.new + begin + old_locale, I18n.locale = I18n.locale, :da + controller.process(:index) + assert_equal "With String Hey verden", controller.response_body + ensure + I18n.locale = old_locale + end + end end end end -- 1.6.6.rc1.42.gf9ad7.dirty