Permalink
Browse files

Fixes a bug where layouts provided with an absolute path would not be…

… found because they were prefixed by 'layouts'. This bug only appears if the path does not contain the word 'layouts'.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#3207 state:committed]
  • Loading branch information...
1 parent 4a11ca1 commit 8371d6f0c1948d3201c1db1fea4b1604a238d48d @gaspard gaspard committed with NZKoz Sep 15, 2009
View
2 actionpack/lib/action_controller/layout.rb
@@ -221,7 +221,7 @@ def default_layout #:nodoc:
end
def find_layout(layout, format, html_fallback=false) #:nodoc:
- view_paths.find_template(layout.to_s =~ /layouts\// ? layout : "layouts/#{layout}", format, html_fallback)
+ view_paths.find_template(layout.to_s =~ /\A\/|layouts\// ? layout : "layouts/#{layout}", format, html_fallback)
rescue ActionView::MissingTemplate
raise if Mime::Type.lookup_by_extension(format.to_s).html?
end
View
11 actionpack/test/controller/layout_test.rb
@@ -83,6 +83,11 @@ class AbsolutePathLayoutController < LayoutTest
layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/layouts/layout_test.rhtml')
end
+class AbsolutePathWithoutLayoutsController < LayoutTest
+ # Absolute layout path without 'layouts' in it.
+ layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/abs_path_layout.rhtml')
+end
+
class HasOwnLayoutController < LayoutTest
layout 'item'
end
@@ -153,6 +158,12 @@ def test_absolute_pathed_layout
get :hello
assert_equal "layout_test.rhtml hello.rhtml", @response.body.strip
end
+
+ def test_absolute_pathed_layout_without_layouts_in_path
+ @controller = AbsolutePathWithoutLayoutsController.new
+ get :hello
+ assert_equal "abs_path_layout.rhtml hello.rhtml", @response.body.strip
+ end
end
class RenderWithTemplateOptionController < LayoutTest
View
1 actionpack/test/fixtures/layout_tests/abs_path_layout.rhtml
@@ -0,0 +1 @@
+abs_path_layout.rhtml <%= yield %>

0 comments on commit 8371d6f

Please sign in to comment.