Last active
August 29, 2015 14:06
-
-
Save vasilakisfil/df710f309bed287914c5 to your computer and use it in GitHub Desktop.
authentication_helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AuthenticationHelper | |
def sign_in(user) | |
header('Authorization', "Token token=\"#{user.authentication_token}\", user_email=\"#{user.email}\"") | |
end | |
def create_and_sign_in_user | |
user = FactoryGirl.create(:user) | |
sign_in(user) | |
return user | |
end | |
alias_method :create_and_sign_in_another_user, :create_and_sign_in_user | |
def create_and_sign_in_super_admin | |
super_admin = FactoryGirl.create(:super_admin) | |
sign_in(super_admin) | |
return super_admin | |
end | |
end | |
RSpec.configure do |config| | |
config.include AuthenticationHelper, :type=>:api | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment