I am migrating my application from a user authentication mechanism to authlogic, and itβs hard for me to figure out how to verify that a new user has logged in after creating it. My old test was as follows:
describe UsersController do
.
.
.
before(:each) do
activate_authlogic
@attr = { :username => "New User", :email => "user@example.com",
:password => "foobar", :password_confirmation => "foobar" }
end
.
.
.
it "should sign the user in" do
post :create, :user => @attr
controller.should be_signed_in
end
where is signed_in? defined in app / helpers / user_sessions_helper.rb and included in the application controller:
def signed_in?
!current_user.nil?
end
I expect this test to pass, but signed_in? returns false. Any ideas? I assume that I should ask for a UserSession if: the user is logged in, but I'm not sure how authlogic allows me to do this.
Any hints, tips or tricks are welcome.
source
share