In section 9.2.1 of Michael Hartl’s new Rails Tutorial Book (3.2), there is a test defined to ensure that if a user is logged in they cannot update (PUT) changes to another user. If this is attempted, the user should be redirected to the home page. Because a webpage can’t directly issue a PUT, the RSPEC test uses:
before { put user_path(wrong_user) }
{ response.should redirect_to(root_path) }
This test case fails and looking at the log it seems to be exiting on because the first before_filter (signed_in_user) in the UserController is redirecting to the sign in page.
Here is my github page for this sample app:
https://github.com/treetopvt/sample_app
In chapter 8 there was an exercise to switch from cookies to sessions. in my SessionsHelper module I replaced
with
The move to sessions worked fine, but because I was no longer “permanently” storing a cookie, the test fails. I undid my exercise changes from Chapter 8, moving back to cookies, and all tests pass. Now, any ideas on how I change my authorization test to work while using sessions? This is my current test: