2022-11-28 13:19:50 +01:00
|
|
|
require 'swagger_helper'
|
|
|
|
|
|
|
|
describe 'Financial Transaction', type: :request do
|
|
|
|
include ApiHelper
|
2022-11-29 18:55:45 +01:00
|
|
|
let!(:finance_user) { create(:user, groups: [create(:workgroup, role_finance: true)]) }
|
|
|
|
let!(:api_scopes) { ['finance:read', 'finance:write'] }
|
|
|
|
let(:api_access_token) { create(:oauth2_access_token, resource_owner_id: finance_user.id, scopes: api_scopes&.join(' ')).token }
|
|
|
|
let(:financial_transaction) { create(:financial_transaction, user: user) }
|
2022-11-28 13:19:50 +01:00
|
|
|
|
|
|
|
path '/financial_transactions' do
|
|
|
|
get 'financial transactions' do
|
|
|
|
tags 'Financial Transaction'
|
|
|
|
produces 'application/json'
|
2022-11-29 18:55:45 +01:00
|
|
|
parameter name: "per_page", in: :query, type: :integer, required: false
|
|
|
|
parameter name: "page", in: :query, type: :integer, required: false
|
2022-11-28 13:19:50 +01:00
|
|
|
|
|
|
|
response '200', 'success' do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
meta: {
|
2022-12-12 12:28:06 +01:00
|
|
|
'$ref' => '#/components/schemas/Meta'
|
2022-11-28 13:19:50 +01:00
|
|
|
},
|
|
|
|
financial_transaction: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
'$ref': '#/components/schemas/FinancialTransaction'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-12 12:59:06 +01:00
|
|
|
|
2022-11-28 13:19:50 +01:00
|
|
|
run_test!
|
|
|
|
end
|
2022-12-12 12:59:06 +01:00
|
|
|
it_handles_invalid_token_and_scope
|
2022-11-28 13:19:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/financial_transactions/{id}' do
|
|
|
|
get 'Retrieves a financial transaction ' do
|
2022-12-12 12:28:06 +01:00
|
|
|
tags 'Financial Transaction'
|
2022-11-28 13:19:50 +01:00
|
|
|
produces 'application/json'
|
2022-12-12 15:54:53 +01:00
|
|
|
id_url_param
|
2022-11-28 13:19:50 +01:00
|
|
|
|
|
|
|
response '200', 'financial transaction found' do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
financial_transaction: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
'$ref': '#/components/schemas/FinancialTransaction'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let(:id) { FinancialTransaction.create(user: user).id }
|
|
|
|
run_test!
|
|
|
|
end
|
2022-12-12 12:59:06 +01:00
|
|
|
it_handles_invalid_token_with_id :financial_transaction
|
|
|
|
it_handles_invalid_scope_with_id :financial_transaction
|
|
|
|
it_cannot_find_object 'financial transaction not found'
|
2022-11-28 13:19:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|