Detached Mongrel server cannot seem to find an implicit layout
and therefore renders actions without a layout.
This is a regression from commit 858a420c.
I narrowed it down to this method:
# action_controller/layout.rb
def layout_list
Array(view_paths).sum([]) { |path| Dir["#{path}/layouts/**/*"] }
end
With detached Mongrel this method returns an empty array because
the current working dir is "/" (root), but Path#to_s returns a
relative path since it strips RAILS_ROOT from the
beginning (why?!).
The fix is this glob:
Dir["#{path.path}/layouts/**/*"]
I haven't been able to produce a failing test. I tried something
like:
# this test simulates a detached Mongrel server
def test_application_layout_is_found_with_absolute_paths
old_load_paths = ProductController.view_paths
begin
Dir.chdir("/") do
ProductController.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ]
@controller = ProductController.new
get :hello
assert_equal 'layout_test.rhtml hello.rhtml', @response.body
end
ensure
ProductController.view_paths = old_load_paths
end
end
but I seem to be on the wrong track, I just keep getting
unrelated errors and can't really get an action to render without a
layout.