This project is archived and is in readonly mode.
[PATCH] assert_template wrong behavior for testing layout used to render template?
-
Mike Gehard
I have confirmed that assert_template does not work as you would expect and as the tests show in /actionpack/test/controller/layout_test.rb.
Example:
class HasOwnLayoutController < LayoutTestlayout 'item'
layout 'item123' end
def test_layout_set_when_set_in_controller
@controller = HasOwnLayoutController.new get :hello assert_template :layout => "layouts/item"end
This test still passes with the changed layout.
-
Mike Gehard
- Tag set to patch
Here is the patch that makes checking for layouts independent of checking for partials.
-
Mike Gehard
- Tag changed from patch to activesupport, patch, rails3
-
Jean
- Title changed from assert_template wrong behavior for testing layout used to render template? to [PATCH] assert_template wrong behavior for testing layout used to render template?
I confirm that I have this problem too.
Introduced here : http://github.com/rails/rails/commit/947f86c699b33bd44703b3554db58e...
-
Jean
Is there a problem with the patch ?
It seems to work for me and in the meantime using the old way (@controller.response.layout) raises a deprecation warning which tells us to use template.layout instead. This would be fine except for 2 things :
- @controller.response.template or @controller.template both return nil (even though @controller.response.layout isn't) - The template method itself is in the deprecated helper and I suppose will be deprecated soon enough -
Santiago Pastorino
- Milestone cleared.
- State changed from new to open
- Assigned user set to José Valim
- Importance changed from to Low
This patch does not apply cleanly anymore. Would you mind to do it again, thank you.
-
Jean
I checked out the latest rails 3-0-stable and recreated the patch.
-
Santiago Pastorino
- Assigned user changed from José Valim to Yehuda Katz (wycats)
-
Dave Myron
It seems like the patch will no longer catch
:layout => falsesince it does anif expected_layout = options[:layout]- which will never pass if :layout is false. It should use the original method of checking if the :layout key is present. -
Geoffrey Hichborn
This bug appears to be a symptom of this: http://groups.google.com/group/rubyonrails-talk/browse_thread/threa...
The bug isn't really assert_template, but the fact that using :partial and :layout together force the layout to be a partial.
