API documentation and spec setup

This commit is contained in:
wvengen 2018-10-15 16:47:14 +02:00 committed by wvengen
parent 99ecb75c83
commit 900cc91197
7 changed files with 226 additions and 0 deletions

View file

@ -0,0 +1,18 @@
module ApiHelper
extend ActiveSupport::Concern
included do
let(:user) { create(:user) }
let(:api_access_token) { create(:oauth2_access_token, resource_owner_id: user.id).token }
let(:api_authorization) { "Bearer #{api_access_token}" }
end
# Add authentication to parameters for {Swagger::RspecHelpers#validate}
# @param params [Hash] Query parameters
# @return Query parameters with authentication header
# @see Swagger::RspecHelpers#validate
def api_auth(params = {})
{'_headers' => {'Authorization' => api_authorization }}.deep_merge(params)
end
end