ST Dev


4,110 Experience
41 Lessons Completed
0 Questions Solved


@Chris, I was trying to go through an old version of Rail Tutorial (probably Rails 4) and ran into a similar issue, while creating the authentication system it seems like you said here, we need to define the current_user, logged_in? and other methods again for the tests to work. I finally however, gave up when I realized that I got the error below. It seems counter intuitive though that methods (even helper_methods) defined in the controller cannot be accessed by the TestController, is there any specific reason why this was done?

test_current_user_returns_right_user_when_session_is_nil#ApplicationControllerTest (0.07s)
Minitest::UnexpectedError: NoMethodError: undefined method `session' for nil:NilClass

This is due the usage of session[user_id] in the current_user method which I did include in the ControllerTest