views:

39

answers:

2

If controller A's action redirects to another controller B's action, can i check in A's functional test that B's action template is being rendered?

in controller As fucntional test i.e. assert_template 'controllerB/some_view'

I know that this should be done in controllers Bs tests but I'm wondering if it is technically possible?

I have tried this in my own project but it's failing so i wanted to know if its actually impossible to avoid wasting any time hunting down invisible bugs.

+1  A: 
test "current/index should render others/action template" do
  get :index
  assert_response :success
  assert_template "others/index"
end
Simone Carletti
sorry i never mentioned i was already trying this in my own project code but its failing.
adam
+1  A: 

Rails functional tests do not follow redirects from one controller to another. To test this you need to use an integration test. The Rails Guide for testing can help you get started with integration tests

Thomas Brice
thanks tomtoday! you cleared up any doubts i had. Sometimes you wonder if its your own code, the machine or just the rules of the framework.
adam
Glad to hear that helped. I have spent more time that I care to admit on the very same problem. Very frustrating.
Thomas Brice