API documentation and spec setup
This commit is contained in:
parent
99ecb75c83
commit
900cc91197
7 changed files with 226 additions and 0 deletions
18
spec/support/api_helper.rb
Normal file
18
spec/support/api_helper.rb
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue