-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5.4 current_user is nil #69
Comments
You need a before callback for the authenticate method on the |
I just added Lots of them with this error:
|
Add it just for the update action: before_action :authenticate_user!, only: [:update] |
Ok back to just the 5 errors now: Failures:
|
It seems that the controller is not rendering the json object |
Yeah. Been doing a little digging and I found some entries on Stack Overflow that said to include |
How are you rendering the controller json response? |
My test fails and I get the errors..
Finished in 0.22121 seconds (files took 1.66 seconds to load) Failed examples: rspec ./spec/controllers/api/v1/users_controller_spec.rb:101 # Api::V1::UsersController PUT/PATCH #update when is not created should respond with 422 But once I remove before_action :authenticate_with_token!, only: [:update, :destroy] from the Users Controller, the test passes. What could be the cause? |
Can you share the controller's code along with the tests and routes please? |
I've been following the tutorial fine so far but I'm getting stuck at 5.4
In my
user_controllers_spec.rb
tests I'm able to set the request headers to the user's auth token that's provided in the factory.However, by the time I get into the
users_controller.rb
I find thatUser.find_by(auth_token: request.headers['Authorization']) == nil
and hence I don't have a
current_user
in myupdate
action.You can find my latest code here should it help: https://github.com/nrosella/market_place_api
Any help would be great!
Thanks
The text was updated successfully, but these errors were encountered: