page/per_pagefor each controller, some summaries/descriptions updated

This commit is contained in:
viehlieb 2022-12-05 17:07:10 +01:00 committed by Philipp Rothmann
parent be4f4d6c13
commit af6e06dfe7
9 changed files with 165 additions and 156 deletions

View file

@ -13,11 +13,14 @@ describe 'User', type: :request do
end
path '/user/financial_transactions' do
post 'financial transaction to create' do
post 'create new financial transaction (requires enabled self service)' do
tags 'User', 'FinancialTransaction'
consumes 'application/json'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
let(:page) { 1 }
let(:per_page) { 20 }
parameter name: :financial_transaction, in: :body, schema: {
type: :object,
properties: {
@ -45,7 +48,7 @@ describe 'User', type: :request do
# 403
# description: user has no ordergroup, is below minimum balance, self service is disabled, or missing scope
it_handles_invalid_scope_with_id(:financial_transaction)
it_handles_invalid_scope_with_id(:financial_transaction, 'user has no ordergroup, is below minimum balance, self service is disabled, or missing scope')
# TODO: fix 404 and 422
# 404
@ -68,10 +71,8 @@ describe 'User', type: :request do
# schema '$ref' => '#/components/schemas/Error422'
# run_test!
# end
end
get 'financial transactions of the members ordergroup' do
get "financial transactions of the member's ordergroup" do
tags 'User', 'Financial Transaction'
produces 'application/json'
@ -127,7 +128,7 @@ describe 'User', type: :request do
# 401
it_handles_invalid_token_with_id(:financial_transaction)
# 403
it_handles_invalid_scope_with_id(:financial_transaction)
it_handles_invalid_scope_with_id(:financial_transaction, 'user has no ordergroup or missing scope')
# 404
response '404', 'financial transaction not found' do
schema type: :object, properties: {

View file

@ -16,58 +16,13 @@ describe 'User', type: :request do
end
path '/user/group_order_articles' do
post 'group order article to create' do
tags 'User', 'Order'
consumes 'application/json'
produces 'application/json'
parameter name: :group_order_article, in: :body, schema: {
type: :object,
properties: {
order_article_id: { type: :integer },
quantity: { type: :integer },
tolerance: { type: :string }
}
}
let(:group_order_article) { { order_article_id: order_articles.last.id, quantity: 1, tolerance: 2 } }
response '200', 'success' do
schema type: :object, properties: {
group_order_article_for_create: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticleForCreate'
}
}
}
run_test!
end
# 401
it_handles_invalid_token_with_id(:group_order_article)
# 403
# description: user has no ordergroup, is below minimum balance, self service is disabled, or missing scope
it_handles_invalid_scope_with_id(:group_order_article)
# 404
response '404', 'order article not found in open orders' do
let(:group_order_article) { { order_article_id: 'invalid', quantity: 1, tolerance: 2 } }
schema '$ref' => '#/components/schemas/Error404'
run_test!
end
# 422
response '422', 'invalid parameter value' do
let(:group_order_article) { { order_article_id: goa.order_article_id, quantity: 1, tolerance: 2 } }
schema '$ref' => '#/components/schemas/Error422'
run_test!
end
end
get 'group order articles of the members ordergroup' do
get 'group order articles' do
tags 'User', 'Order'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
let(:page) { 1 }
let(:per_page) { 20 }
response '200', 'success' do
schema type: :object, properties: {
meta: {
@ -90,74 +45,65 @@ describe 'User', type: :request do
expect(data['group_order_articles'].first['id']).to eq(goa.id)
end
end
# responses 401 & 403
it_handles_invalid_token_and_scope
end
end
path '/user/group_order_articles/{id}' do
patch 'summary: update a group order article (but delete if quantity and tolerance are zero)' do
tags 'User', 'GroupOrderArticle'
# response 401
it_handles_invalid_token
# response 403
it_handles_invalid_scope('user has no ordergroup or missing scope')
end
post 'create new group order article' do
tags 'User', 'Order'
consumes 'application/json'
produces 'application/json'
parameter name: :id, in: :path, type: :string
parameter name: :group_order_article, in: :body, schema: {
type: :object,
description: 'group order article to create',
properties: {
order_article_id: { type: :integer },
quantity: { type: :integer },
tolerance: { type: :integer }
}
tolerance: { type: :string }
},
required: true
}
let(:id) { goa.id }
let(:group_order_article) { { order_article_id: goa.order_article_id, quantity: 2, tolerance: 2 } }
let(:group_order_article) { { order_article_id: order_articles.last.id, quantity: 1, tolerance: 2 } }
response '200', 'success' do
schema type: :object, properties: {
group_order_article_for_create: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticleForUpdate'
'$ref': '#/components/schemas/GroupOrderArticleForCreate'
}
}
}
run_test!
end
# 401
response 401, 'missing token' do
let(:Authorization) { 'abc' }
schema '$ref' => '#/components/schemas/Error401'
run_test!
end
# 403
response 403, 'missing scope' do
let(:api_scopes) { ['none'] }
schema '$ref' => '#/components/schemas/Error403'
run_test!
end
# 404
response '404', 'group order article not found' do
schema type: :object, properties: {
group_order_article: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticle'
}
}
}
let(:id) { 'invalid' }
run_test!
end
#422
response '422', 'invalid parameter value' do
let(:group_order_article) { { order_article_id: 'invalid', quantity: -5, tolerance: 'invalid' } }
# 401
it_handles_invalid_token_with_id(:group_order_article)
# 403
# description: user has no ordergroup, is below minimum balance, self service is disabled, or missing scope
it_handles_invalid_scope_with_id(:group_order_article, 'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope')
# 404
response '404', 'order article not found in open orders' do
let(:group_order_article) { { order_article_id: 'invalid', quantity: 1, tolerance: 2 } }
schema '$ref' => '#/components/schemas/Error404'
run_test!
end
# 422
response '422', 'invalid parameter value or group order article already exists' do
let(:group_order_article) { { order_article_id: goa.order_article_id, quantity: 1, tolerance: 2 } }
schema '$ref' => '#/components/schemas/Error422'
run_test!
end
end
end
path '/user/group_order_articles/{id}' do
get 'find group order article by id' do
tags 'User', 'GroupOrderArticle'
produces 'application/json'
@ -180,13 +126,13 @@ describe 'User', type: :request do
end
# 401
response 401, 'missing token' do
response 401, 'not logged-in' do
let(:Authorization) { 'abc' }
schema '$ref' => '#/components/schemas/Error401'
run_test!
end
# 403
response 403, 'missing scope' do
response 403, 'user has no ordergroup or missing scope' do
let(:api_scopes) { ['none'] }
schema '$ref' => '#/components/schemas/Error403'
run_test!
@ -205,6 +151,69 @@ describe 'User', type: :request do
run_test!
end
end
patch 'update a group order article (but delete if quantity and tolerance are zero)' do
tags 'User', 'GroupOrderArticle'
consumes 'application/json'
produces 'application/json'
parameter name: :id, in: :path, type: :string
parameter name: :group_order_article, in: :body, schema: {
type: :object,
description: 'group order article to create',
properties: {
order_article_id: { type: :integer },
quantity: { type: :integer },
tolerance: { type: :string }
},
required: true
}
let(:id) { goa.id }
let(:group_order_article) { { order_article_id: goa.order_article_id, quantity: 2, tolerance: 2 } }
response '200', 'success' do
schema type: :object, properties: {
group_order_article_for_create: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticleForUpdate'
}
}
}
run_test!
end
# 401
response 401, 'not logged-in' do
let(:Authorization) { 'abc' }
schema '$ref' => '#/components/schemas/Error401'
run_test!
end
# 403
response 403, 'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' do
let(:api_scopes) { ['none'] }
schema '$ref' => '#/components/schemas/Error403'
run_test!
end
# 404
response '404', 'order article not found in open orders' do
schema type: :object, properties: {
group_order_article: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticle'
}
}
}
let(:id) { 'invalid' }
run_test!
end
# 422
response '422', 'invalid parameter value' do
let(:group_order_article) { { order_article_id: 'invalid', quantity: -5, tolerance: 'invalid' } }
schema '$ref' => '#/components/schemas/Error422'
run_test!
end
end
delete 'remove group order article' do
tags 'User', 'Order'
@ -228,32 +237,21 @@ describe 'User', type: :request do
end
# 401
response 401, 'missing token' do
response 401, 'not logged-in' do
let(:Authorization) { 'abc' }
schema '$ref' => '#/components/schemas/Error401'
run_test!
end
# 403
response 403, 'missing scope' do
response 403, 'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' do
let(:api_scopes) { ['none'] }
schema '$ref' => '#/components/schemas/Error403'
run_test!
end
# 404
response '404', 'group order article not found' do
schema type: :object, properties: {
group_order_article: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticle'
}
}
}
let(:id) { 'invalid' }
run_test!
end
it_cannot_find_object('order article not found in open orders')
end
end
end