Login user UserSession.create for rspec not working

msaspence
Sun, 13 Feb 2011 20:30:49 -0000

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
end

to the spec helper, based mainly on the example at
https://github.com/akm/authlogic-rspec-example

any ideas?

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at