Skip to content

Instantly share code, notes, and snippets.

@vasilakisfil
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasilakisfil/df710f309bed287914c5 to your computer and use it in GitHub Desktop.
Save vasilakisfil/df710f309bed287914c5 to your computer and use it in GitHub Desktop.
authentication_helper
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