How does the provider work when cookies are added

(Salman, Freelance Developer) #1


I’m looking at the code in the default auth provider and I don’t understand how it could be working. I’m trying to understand how the tests are created with current_user and the providers.

During login the cookies are written the the cookies object that is passed in as a parameter, which is the current request objects cookie collection in rails:

But when you check the current_user method, it is looking in the @request object which is created in the constructor and it is a rack request.

If I put some puts statement in the log_on_user I can tell that the cookie is being added to only one of the request collections:

puts "cookies #{cookies.count}"
puts “@req.cookies #{@request.cookies.count}”

The output is 1 and 0, so the @requests.cookies collection is empty.

So I’m not sure how the rspec tests are working? Can someone explain this to me?