robodisco
robodisco

Reputation: 4272

Rails Functional Tests - I can't assert a template from another controller's view in my functional test

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 functional 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.

Upvotes: 1

Views: 837

Answers (2)

Thomas Brice
Thomas Brice

Reputation: 362

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

Upvotes: 3

Simone Carletti
Simone Carletti

Reputation: 176382

test "current/index should render others/action template" do
  get :index
  assert_response :success
  assert_template "others/index"
end

Upvotes: 1

Related Questions