From 3aaed4aa44ed5f157d2a297afdee4cdbebb92d15 Mon Sep 17 00:00:00 2001 From: Eugene Pimenov Date: Thu, 4 Feb 2010 17:51:17 +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 8acfe6c..6cbefb3 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -124,7 +124,7 @@ module ActionView handler = Template.handler_class_for_extension(m[5]) format = Mime[details.last] && details.pop.to_sym - locale = details.last && details.pop.to_sym + locale = details.last && [details.pop.to_sym] virtual_path = (m[1].gsub("#{@path}/", "") << details.join(".")) diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb index b6d89ea..a4c35fd 100644 --- a/actionpack/test/abstract/layouts_test.rb +++ b/actionpack/test/abstract/layouts_test.rb @@ -14,7 +14,9 @@ module AbstractControllerTests "layouts/abstract_controller_tests/layouts/with_string_implied_child.erb" => "With Implied <%= yield %>", "layouts/overwrite.erb" => "Overwrite <%= 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 @@ -152,7 +154,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 @@ -272,6 +282,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