Skip to content

Instantly share code, notes, and snippets.

@philcrissman
Created July 29, 2010 13:51
Show Gist options
  • Save philcrissman/498171 to your computer and use it in GitHub Desktop.
Save philcrissman/498171 to your computer and use it in GitHub Desktop.
# ... other require statements
require 'authlogic/test_case'
class ActiveSupport::TestCase
# ... whatever is already in here
def login_as(user)
activate_authlogic
user_session = UserSession.new(:email => user.email, :password => 'asdfasdf')
user_session.save!
return false
end
end
## Then in your test...
class UsersControllerTest # etc
setup do
@user = # make a user with User.new, factory, etc
login_as(@user)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment