Skip to content

Commit

Permalink
Fix layouts with absolute paths [#2134 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
thedarkone authored and josh committed Mar 6, 2009
1 parent 5b7527c commit 3191535
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion actionpack/lib/action_controller/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ def render(options = nil, extra_options = {}, &block) #:doc:
layout = pick_layout(options)
response.layout = layout.path_without_format_and_extension if layout
logger.info("Rendering template within #{layout.path_without_format_and_extension}") if logger && layout
layout = layout.path_without_format_and_extension if layout

if content_type = options[:content_type]
response.content_type = content_type.to_s
Expand Down
12 changes: 11 additions & 1 deletion actionpack/test/controller/layout_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def test_namespaced_controllers_auto_detect_layouts
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
Expand Down Expand Up @@ -137,12 +141,18 @@ def test_exempt_from_layout_honored_by_render_template
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
Expand Down

0 comments on commit 3191535

Please sign in to comment.