Initial commit
This commit is contained in:
16
spec/support/authentication_helper.rb
Normal file
16
spec/support/authentication_helper.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
Reference in New Issue
Block a user