When a non-signed-in user tries to access edit or update actions of the users controller, the app should redirect (e.g. to signin page or root_path).
App works fine but tests for this are failing with a following error:
Failure/Error: specify { response.should redirect_to(signin_path) }
Expected response to be a redirect to <http://www.example.com/signin> but was a redirect to <https://www.example.com/users/468>
# ./spec/requests/authentication_pages_spec.rb:69:in `block (6 levels) in <top (required)>'
What might be a problem here? How to debug it?
All code is here: https://github.com/tomek-rusilko/miniatury_katalog_2
And failing tests are here: https://github.com/tomek-rusilko/miniatury_katalog_2/blob/master/spec/requests/authentication_pages_spec.rb (lines: 63 and 105)
Finally had time to re-visit this. I pulled your code from github and had the same problem. I pared the test down to this:
As you noted, the binding.pry in the controller code did not stop the execution as I thought it would. After a lot of useless digging/googling around, finally noticed in the log/test.log:
that it was attempting to use SSL. My version of the Rails Tutorial is only using SSL in production. I removed ‘force_ssl’ from the application_controller.rb and then all tests passed. I’m still new to Rails and didn’t even realize there are logs but I know now!