add orders spec
This commit is contained in:
parent
ab26520f7a
commit
be4f4d6c13
2 changed files with 95 additions and 0 deletions
55
spec/requests/api/orders_spec.rb
Normal file
55
spec/requests/api/orders_spec.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
require 'swagger_helper'
|
||||
|
||||
describe 'Orders', type: :request do
|
||||
include ApiHelper
|
||||
let(:api_scopes) { ['orders:read'] }
|
||||
|
||||
path '/orders' do
|
||||
get 'orders' do
|
||||
tags 'Order'
|
||||
produces 'application/json'
|
||||
parameter name: 'page[number]', in: :query, type: :integer, required: false
|
||||
parameter name: 'page[size]', in: :query, type: :integer, required: false
|
||||
|
||||
let(:order) { create(:order) }
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
meta: {
|
||||
'$ref' => '#/components/schemas/Meta'
|
||||
},
|
||||
ordes: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/Order'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run_test!
|
||||
end
|
||||
|
||||
it_handles_invalid_token_and_scope
|
||||
end
|
||||
end
|
||||
|
||||
path '/orders/{id}' do
|
||||
get 'Order' do
|
||||
tags 'Order'
|
||||
produces 'application/json'
|
||||
parameter name: 'id', in: :path, type: :integer, minimum: 1, required: true
|
||||
let(:order) { create(:order) }
|
||||
let(:id) { order.id }
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
'$ref': '#/components/schemas/Order'
|
||||
}
|
||||
|
||||
run_test! do |response|
|
||||
expect(JSON.parse(response.body)['order']['id']).to eq order.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -34,6 +34,46 @@ RSpec.configure do |config|
|
|||
},
|
||||
required: %w(recordCount pageCount currentPage pageSize)
|
||||
},
|
||||
Order: {
|
||||
type: :object,
|
||||
properties: {
|
||||
id: {
|
||||
type: :integer
|
||||
},
|
||||
name: {
|
||||
type: :string,
|
||||
description: "name of the order's supplier (or stock)"
|
||||
},
|
||||
starts: {
|
||||
type: :string,
|
||||
format: 'date-time',
|
||||
description: 'when the order was opened'
|
||||
},
|
||||
ends: {
|
||||
type: ['string', 'null'],
|
||||
format: 'date-time',
|
||||
description: 'when the order will close or was closed'
|
||||
},
|
||||
boxfill: {
|
||||
type: ['string', 'null'],
|
||||
format: 'date-time',
|
||||
description: 'when the order will enter or entered the boxfill phase'
|
||||
},
|
||||
pickup: {
|
||||
type: ['string', 'null'],
|
||||
format: :date,
|
||||
description: 'pickup date'
|
||||
},
|
||||
is_open: {
|
||||
type: :boolean,
|
||||
description: 'if the order is currently open or not'
|
||||
},
|
||||
is_boxfill: {
|
||||
type: :boolean,
|
||||
description: 'if the order is currently in the boxfill phase or not'
|
||||
}
|
||||
}
|
||||
},
|
||||
Article: {
|
||||
type: :object,
|
||||
properties: {
|
||||
|
|
Loading…
Reference in a new issue