28_introduce_rswag #35

Merged
philipp merged 46 commits from 28_introduce_rswag into develop 2023-01-05 13:45:47 +01:00
Showing only changes of commit eac550daa9 - Show all commits

View file

@ -21,8 +21,8 @@ describe 'User', type: :request do
produces 'application/json' produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false parameter name: "page", in: :query, type: :integer, required: false
let(:page) { 1 } q_ordered_url_param
let(:per_page) { 20 }
response '200', 'success' do response '200', 'success' do
schema type: :object, properties: { schema type: :object, properties: {
meta: { '$ref': '#/components/schemas/Meta' }, meta: { '$ref': '#/components/schemas/Meta' },
@ -40,35 +40,27 @@ describe 'User', type: :request do
end end
end end
# response 401
it_handles_invalid_token it_handles_invalid_token
it_handles_invalid_scope 'user has no ordergroup or missing scope'
# response 403
it_handles_invalid_scope('user has no ordergroup or missing scope')
end end
post 'create new group order article' do post 'create new group order article' do
tags 'User', 'Order' tags 'User', 'Order'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
parameter name: :group_order_article, in: :body, schema: { parameter name: :group_order_article, in: :body,
type: :object,
description: 'group order article to create', description: 'group order article to create',
properties: { required: true,
order_article_id: { type: :integer }, schema: { '$ref': '#/components/schemas/GroupOrderArticleForCreate' }
quantity: { type: :integer },
tolerance: { type: :string }
},
required: true
}
let(:group_order_article) { { order_article_id: order_articles.last.id, quantity: 1, tolerance: 2 } } let(:group_order_article) { { order_article_id: order_articles.last.id, quantity: 1, tolerance: 2 } }
response '200', 'success' do response '200', 'success' do
schema type: :object, properties: { schema type: :object, properties: {
group_order_article_for_create: { group_order_article: {
type: :object, '$ref': '#/components/schemas/GroupOrderArticle'
items: { },
'$ref': '#/components/schemas/GroupOrderArticleForCreate' order_article: {
} '$ref': '#/components/schemas/OrderArticle'
} }
} }
run_test! run_test!
@ -77,7 +69,6 @@ describe 'User', type: :request do
it_handles_invalid_token_with_id it_handles_invalid_token_with_id
it_handles_invalid_scope_with_id 'user has no ordergroup, order not open, is below minimum balance, has not enough apple points, or missing scope' it_handles_invalid_scope_with_id '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 response '404', 'order article not found in open orders' do
let(:group_order_article) { { order_article_id: 'invalid', quantity: 1, tolerance: 2 } } let(:group_order_article) { { order_article_id: 'invalid', quantity: 1, tolerance: 2 } }
schema '$ref' => '#/components/schemas/Error404' schema '$ref' => '#/components/schemas/Error404'
@ -95,19 +86,20 @@ describe 'User', type: :request do
path '/user/group_order_articles/{id}' do path '/user/group_order_articles/{id}' do
get 'find group order article by id' do get 'find group order article by id' do
tags 'User', 'GroupOrderArticle' tags 'User', 'Order'
produces 'application/json' produces 'application/json'
id_url_param id_url_param
response '200', 'success' do response '200', 'success' do
schema type: :object, properties: { schema type: :object, properties: {
group_order_article: { group_order_article: {
type: :object,
items: {
'$ref': '#/components/schemas/GroupOrderArticle' '$ref': '#/components/schemas/GroupOrderArticle'
},
order_article: {
'$ref': '#/components/schemas/OrderArticle'
} }
} }
}
let(:id) { goa.id } let(:id) { goa.id }
run_test! do |response| run_test! do |response|
data = JSON.parse(response.body) data = JSON.parse(response.body)
@ -121,21 +113,15 @@ describe 'User', type: :request do
end end
patch 'update a group order article (but delete if quantity and tolerance are zero)' do patch 'update a group order article (but delete if quantity and tolerance are zero)' do
tags 'User', 'GroupOrderArticle' tags 'User', 'Order'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
id_url_param id_url_param
parameter name: :group_order_article, in: :body,
description: 'group order article update',
required: true,
schema: { '$ref': '#/components/schemas/GroupOrderArticleForUpdate' }
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(: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: goa.order_article_id, quantity: 2, tolerance: 2 } }
@ -144,7 +130,7 @@ describe 'User', type: :request do
group_order_article_for_create: { group_order_article_for_create: {
type: :object, type: :object,
items: { items: {
'$ref': '#/components/schemas/GroupOrderArticleForUpdate'
} }
} }
} }