Files
old-holivud2/spec/support/authentication_helper.rb
2020-05-31 22:38:19 +02:00

17 lines
379 B
Ruby

module AuthenticationHelper
def sign_in_to_api(user)
request.headers.merge!(api_authentication_header(user))
end
def api_authentication_header(user)
token = Knock::AuthToken.new(payload: { sub: user.id }).token
{
'Authorization': "Bearer #{token}"
}
end
end
RSpec.configure do |config|
config.include AuthenticationHelper, type: :controller
end