Login user UserSession.create for rspec not working

I’ve got a show action for a map object which should return 200 if the
current_user is the maps owner

I have defined a method on my user object “current?” which returns
true or false if that user is the same as the current user

I have model spec set up for that which mocks UserSession.find.user
and that works fine

But for the controller test I want it to be closer to a functional
test and use the real UserSession.find.user

So Im trying to do UserSession.create in the test
When I do UserSession.find.user after that in the spec the session has
been created but in the controller action the session hasn’t be set,
and therefore .current? returns false

I’ve added

require ‘authlogic/test_case’

class ActionController::TestCase
setup :activate_authlogic

to the spec helper, based mainly on the example at

any ideas?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs