wip rswagging
This commit is contained in:
parent
c6dd8a18a3
commit
305d1055c4
4 changed files with 194 additions and 3 deletions
|
@ -11,6 +11,7 @@ describe 'Financial Transaction Classes', type: :request do
|
|||
parameter name: "page[size]", in: :query, type: :integer, required: false
|
||||
|
||||
let!(:financial_transaction_class) { create(:financial_transaction_class) }
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
meta: {
|
||||
|
@ -33,7 +34,7 @@ describe 'Financial Transaction Classes', type: :request do
|
|||
end
|
||||
|
||||
path '/financial_transaction_classes/{id}' do
|
||||
get 'Retrieves an financial transaction class' do
|
||||
get 'Retrieves a financial transaction class' do
|
||||
tags 'Category'
|
||||
produces 'application/json'
|
||||
parameter name: :id, in: :path, type: :string
|
||||
|
@ -52,7 +53,7 @@ describe 'Financial Transaction Classes', type: :request do
|
|||
end
|
||||
|
||||
response '401', 'not logged in' do
|
||||
schema type: :object, properties: {
|
||||
schema type: :object, properties: {
|
||||
financial_transaction_classes: {
|
||||
type: :array,
|
||||
items: {
|
||||
|
@ -61,7 +62,7 @@ describe 'Financial Transaction Classes', type: :request do
|
|||
}
|
||||
}
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:id) { FinancialTransactionClass.create(name: 'dairy').id }
|
||||
let(:id) { FinancialTransactionClass.create(name: 'TestTransaction').id }
|
||||
run_test!
|
||||
end
|
||||
|
||||
|
|
82
spec/requests/api/financial_transaction_types_spec.rb
Normal file
82
spec/requests/api/financial_transaction_types_spec.rb
Normal file
|
@ -0,0 +1,82 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Financial Transaction types', type: :request do
|
||||
include ApiHelper
|
||||
|
||||
path '/financial_transaction_types' do
|
||||
get 'financial transaction types' do
|
||||
tags 'Category'
|
||||
produces 'application/json'
|
||||
parameter name: "page[number]", in: :query, type: :integer, required: false
|
||||
parameter name: "page[size]", in: :query, type: :integer, required: false
|
||||
|
||||
let!(:financial_transaction_type) { create(:financial_transaction_type) }
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
meta: {
|
||||
'$ref' => '#/components/schemas/pagination'
|
||||
},
|
||||
financial_transaction_type: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransactionType'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let(:page) { { number: 1, size: 20 } }
|
||||
run_test!
|
||||
end
|
||||
|
||||
it_handles_invalid_token
|
||||
end
|
||||
end
|
||||
|
||||
path '/financial_transaction_types/{id}' do
|
||||
get 'Retrieves a financial transaction type' do
|
||||
tags 'Category'
|
||||
produces 'application/json'
|
||||
parameter name: :id, in: :path, type: :string
|
||||
|
||||
response '200', 'financial transaction type found' do
|
||||
schema type: :object, properties: {
|
||||
financial_transaction_types: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransactionType'
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:id) { FinancialTransactionType.create(name: 'TestType').id }
|
||||
run_test!
|
||||
end
|
||||
|
||||
response '401', 'not logged in' do
|
||||
schema type: :object, properties: {
|
||||
financial_transaction_types: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransactionType'
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:id) { FinancialTransactionType.create(name: 'TestType').id }
|
||||
run_test!
|
||||
end
|
||||
|
||||
response '404', 'financial transaction type not found' do
|
||||
schema type: :object, properties: {
|
||||
financial_transaction_types: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransactionType'
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:id) { 'invalid' }
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
84
spec/requests/api/financial_transactions_spec.rb
Normal file
84
spec/requests/api/financial_transactions_spec.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Financial Transaction', type: :request do
|
||||
include ApiHelper
|
||||
|
||||
path '/financial_transactions' do
|
||||
get 'financial transactions' do
|
||||
tags 'Financial Transaction'
|
||||
produces 'application/json'
|
||||
parameter name: "page[number]", in: :query, type: :integer, required: false
|
||||
parameter name: "page[size]", in: :query, type: :integer, required: false
|
||||
|
||||
let!(:financial_transaction) { create(:financial_transaction) }
|
||||
let(:api_scopes) { ['finance:read', 'finance:write'] }
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
meta: {
|
||||
'$ref' => '#/components/schemas/pagination'
|
||||
},
|
||||
financial_transaction: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransaction'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let(:page) { { number: 1, size: 20 } }
|
||||
run_test!
|
||||
end
|
||||
|
||||
it_handles_invalid_token
|
||||
end
|
||||
end
|
||||
|
||||
path '/financial_transactions/{id}' do
|
||||
get 'Retrieves a financial transaction ' do
|
||||
tags 'Category'
|
||||
produces 'application/json'
|
||||
parameter name: :id, in: :path, type: :string
|
||||
|
||||
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
|
||||
|
||||
response '401', 'not logged in' do
|
||||
schema type: :object, properties: {
|
||||
financial_transaction: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransaction'
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:Authorization) { 'abc' }
|
||||
let(:id) { FinancialTransaction.create(name: 'TestTransaction').id }
|
||||
run_test!
|
||||
end
|
||||
|
||||
response '404', 'financial transaction not found' do
|
||||
schema type: :object, properties: {
|
||||
financial_transaction: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/FinancialTransaction'
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:id) { 'invalid' }
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -46,6 +46,18 @@ RSpec.configure do |config|
|
|||
},
|
||||
required: %w[id name]
|
||||
},
|
||||
FinancialTransaction: {
|
||||
type: :object,
|
||||
properties: {
|
||||
id: {
|
||||
type: :integer
|
||||
},
|
||||
name: {
|
||||
type: :string
|
||||
}
|
||||
},
|
||||
required: %w[id financial_transaction_type]
|
||||
},
|
||||
FinancialTransactionClass: {
|
||||
type: :object,
|
||||
properties: {
|
||||
|
@ -58,6 +70,18 @@ RSpec.configure do |config|
|
|||
},
|
||||
required: %w[id name]
|
||||
},
|
||||
FinancialTransactionType: {
|
||||
type: :object,
|
||||
properties: {
|
||||
id: {
|
||||
type: :integer
|
||||
},
|
||||
name: {
|
||||
type: :string
|
||||
}
|
||||
},
|
||||
required: %w[id name financial_transaction_class]
|
||||
},
|
||||
Meta: {
|
||||
type: :object,
|
||||
properties: {
|
||||
|
|
Loading…
Reference in a new issue