Skip to content
Browse files

Add spec authentication helper

  • Loading branch information...
1 parent 656f955 commit 7065e723c20a7423ad1bb94387b6b06e1a2a21be @jomz jomz committed Feb 8, 2014
Showing with 12 additions and 0 deletions.
  1. +12 −0 spec/support/authentication_helper.rb
View
12 spec/support/authentication_helper.rb
@@ -0,0 +1,12 @@
+module AuthenticationHelper
+ def login_as(user)
+ login_user = user.is_a?(User) ? user : FactoryGirl.create(user)
+ flunk "Can't login as non-existing user #{user.to_s}." unless login_user
+ request.session['user_id'] = login_user.id
+ login_user
+ end
+
+ def logout
+ request.session['user_id'] = nil
+ end
+end

0 comments on commit 7065e72

Please sign in to comment.
Something went wrong with that request. Please try again.