From d2e5a07bfe1d8a93941df17fe98f058292924f14 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Thu, 5 Mar 2009 17:12:25 +0100 Subject: [PATCH] Fix layouts with absolute paths. --- actionpack/lib/action_view/template.rb | 3 ++- actionpack/test/controller/layout_test.rb | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 0dd3a7e..ad5d0bb 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -165,7 +165,8 @@ module ActionView #:nodoc: memoize :path_without_extension def path_without_format_and_extension - [base_path, [name, locale].compact.join('.')].compact.join('/') + # return our exact template_path if we are an absolutely pathed template and don't have a view_path to back us up + load_path.kind_of?(Path) ? [base_path, [name, locale].compact.join('.')].compact.join('/') : template_path end memoize :path_without_format_and_extension diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index 28555ee..1575674 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -79,6 +79,10 @@ end class DefaultLayoutController < LayoutTest end +class AbsolutePathLayoutController < LayoutTest + layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/layouts/layout_test.rhtml') +end + class HasOwnLayoutController < LayoutTest layout 'item' end @@ -137,12 +141,18 @@ class LayoutSetInResponseTest < ActionController::TestCase ensure ActionController::Base.exempt_from_layout.delete(/\.rhtml$/) end - + def test_layout_is_picked_from_the_controller_instances_view_path @controller = PrependsViewPathController.new get :hello assert_equal 'layouts/alt', @response.layout end + + def test_absolute_pathed_layout + @controller = AbsolutePathLayoutController.new + get :hello + assert_equal "layout_test.rhtml hello.rhtml", @response.body.strip + end end class RenderWithTemplateOptionController < LayoutTest -- 1.6.0.1