17 lines
379 B
Ruby
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
|