28_introduce_rswag #35
9 changed files with 165 additions and 156 deletions
|
@ -7,18 +7,16 @@ describe 'Article Categories', type: :request do
|
||||||
get 'article categories' do
|
get 'article categories' do
|
||||||
tags 'Category'
|
tags 'Category'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: "page[number]", in: :query, type: :integer, required: false
|
parameter name: "per_page", in: :query, type: :integer, required: false
|
||||||
parameter name: "page[size]", in: :query, type: :integer, required: false
|
parameter name: "page", in: :query, type: :integer, required: false
|
||||||
|
let(:page) { 1 }
|
||||||
let!(:order_article) { create(:order, article_count: 1).order_articles.first }
|
let(:per_page) { 10 }
|
||||||
let!(:stock_article) { create(:stock_article) }
|
let(:order_article) { create(:order, article_count: 1).order_articles.first }
|
||||||
let!(:stock_order_article) { create(:stock_order, article_ids: [stock_article.id]).order_articles.first }
|
let(:stock_article) { create(:stock_article) }
|
||||||
|
let(:stock_order_article) { create(:stock_order, article_ids: [stock_article.id]).order_articles.first }
|
||||||
|
|
||||||
response '200', 'success' do
|
response '200', 'success' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
meta: {
|
|
||||||
'$ref' => '#/components/schemas/pagination'
|
|
||||||
},
|
|
||||||
article_categories: {
|
article_categories: {
|
||||||
type: :array,
|
type: :array,
|
||||||
items: {
|
items: {
|
||||||
|
@ -26,8 +24,6 @@ describe 'Article Categories', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:page) { { number: 1, size: 20 } }
|
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +32,7 @@ describe 'Article Categories', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
path '/article_categories/{id}' do
|
path '/article_categories/{id}' do
|
||||||
get 'Retrieves an article category' do
|
get 'find article category by id' do
|
||||||
tags 'Category'
|
tags 'Category'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: :id, in: :path, type: :string
|
parameter name: :id, in: :path, type: :string
|
||||||
|
|
|
@ -7,16 +7,16 @@ describe 'Financial Transaction Classes', type: :request do
|
||||||
get 'financial transaction classes' do
|
get 'financial transaction classes' do
|
||||||
tags 'Category'
|
tags 'Category'
|
||||||
produces 'application/json'
|
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_class) { create(:financial_transaction_class) }
|
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) { 10 }
|
||||||
|
|
||||||
|
let(:financial_transaction_class) { create(:financial_transaction_class) }
|
||||||
|
|
||||||
response '200', 'success' do
|
response '200', 'success' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
meta: {
|
|
||||||
'$ref' => '#/components/schemas/pagination'
|
|
||||||
},
|
|
||||||
financial_transaction_class: {
|
financial_transaction_class: {
|
||||||
type: :array,
|
type: :array,
|
||||||
items: {
|
items: {
|
||||||
|
@ -25,7 +25,6 @@ describe 'Financial Transaction Classes', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:page) { { number: 1, size: 20 } }
|
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,13 @@ describe 'Financial Transaction types', type: :request do
|
||||||
get 'financial transaction types' do
|
get 'financial transaction types' do
|
||||||
tags 'Category'
|
tags 'Category'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: "page[number]", in: :query, type: :integer, required: false
|
parameter name: "per_page", in: :query, type: :integer, required: false
|
||||||
parameter name: "page[size]", in: :query, type: :integer, required: false
|
parameter name: "page", in: :query, type: :integer, required: false
|
||||||
|
let(:page) { 1 }
|
||||||
let!(:financial_transaction_type) { create(:financial_transaction_type) }
|
let(:per_page) { 10 }
|
||||||
|
let(:financial_transaction_type) { create(:financial_transaction_type) }
|
||||||
response '200', 'success' do
|
response '200', 'success' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
meta: {
|
|
||||||
'$ref' => '#/components/schemas/pagination'
|
|
||||||
},
|
|
||||||
financial_transaction_type: {
|
financial_transaction_type: {
|
||||||
type: :array,
|
type: :array,
|
||||||
items: {
|
items: {
|
||||||
|
@ -23,8 +21,6 @@ describe 'Financial Transaction types', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:page) { { number: 1, size: 20 } }
|
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +29,7 @@ describe 'Financial Transaction types', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
path '/financial_transaction_types/{id}' do
|
path '/financial_transaction_types/{id}' do
|
||||||
get 'Retrieves a financial transaction type' do
|
get 'find financial transaction type by id' do
|
||||||
tags 'Category'
|
tags 'Category'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: :id, in: :path, type: :string
|
parameter name: :id, in: :path, type: :string
|
||||||
|
|
|
@ -56,7 +56,7 @@ describe 'Financial Transaction', type: :request do
|
||||||
let(:id) { FinancialTransaction.create(user: user).id }
|
let(:id) { FinancialTransaction.create(user: user).id }
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
it_handles_invalid_scope_with_id(:financial_transaction)
|
it_handles_invalid_scope_with_id(:financial_transaction, 'missing scope or no permission')
|
||||||
|
|
||||||
response '404', 'financial transaction not found' do
|
response '404', 'financial transaction not found' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
|
@ -71,7 +71,7 @@ describe 'Financial Transaction', type: :request do
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
# response 403
|
# response 403
|
||||||
it_handles_invalid_scope_with_id(:financial_transaction)
|
it_handles_invalid_scope_with_id(:financial_transaction, 'missing scope or no permission')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,8 +7,10 @@ describe 'Order Articles', type: :request do
|
||||||
get 'order articles' do
|
get 'order articles' do
|
||||||
tags 'Order'
|
tags 'Order'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: 'page[number]', in: :query, type: :integer, required: false
|
parameter name: "per_page", in: :query, type: :integer, required: false
|
||||||
parameter name: 'page[size]', in: :query, type: :integer, required: false
|
parameter name: "page", in: :query, type: :integer, required: false
|
||||||
|
let(:page) { 1 }
|
||||||
|
let(:per_page) { 10 }
|
||||||
parameter name: 'q', in: :query, required: false,
|
parameter name: 'q', in: :query, required: false,
|
||||||
description: "'member' show articles ordered by the user's ordergroup, 'all' by all members, and 'supplier' ordered at the supplier",
|
description: "'member' show articles ordered by the user's ordergroup, 'all' by all members, and 'supplier' ordered at the supplier",
|
||||||
schema: {
|
schema: {
|
||||||
|
|
|
@ -8,8 +8,10 @@ describe 'Orders', type: :request do
|
||||||
get 'orders' do
|
get 'orders' do
|
||||||
tags 'Order'
|
tags 'Order'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: 'page[number]', in: :query, type: :integer, required: false
|
parameter name: "per_page", in: :query, type: :integer, required: false
|
||||||
parameter name: 'page[size]', in: :query, type: :integer, required: false
|
parameter name: "page", in: :query, type: :integer, required: false
|
||||||
|
let(:page) { 1 }
|
||||||
|
let(:per_page) { 20 }
|
||||||
|
|
||||||
let(:order) { create(:order) }
|
let(:order) { create(:order) }
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,14 @@ describe 'User', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
path '/user/financial_transactions' do
|
path '/user/financial_transactions' do
|
||||||
post 'financial transaction to create' do
|
post 'create new financial transaction (requires enabled self service)' do
|
||||||
tags 'User', 'FinancialTransaction'
|
tags 'User', 'FinancialTransaction'
|
||||||
consumes 'application/json'
|
consumes 'application/json'
|
||||||
produces '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: {
|
parameter name: :financial_transaction, in: :body, schema: {
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -45,7 +48,7 @@ describe 'User', type: :request do
|
||||||
|
|
||||||
# 403
|
# 403
|
||||||
# description: user has no ordergroup, is below minimum balance, self service is disabled, or missing scope
|
# 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
|
# TODO: fix 404 and 422
|
||||||
# 404
|
# 404
|
||||||
|
@ -68,10 +71,8 @@ describe 'User', type: :request do
|
||||||
# schema '$ref' => '#/components/schemas/Error422'
|
# schema '$ref' => '#/components/schemas/Error422'
|
||||||
# run_test!
|
# run_test!
|
||||||
# end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
get "financial transactions of the member's ordergroup" do
|
||||||
get 'financial transactions of the members ordergroup' do
|
|
||||||
tags 'User', 'Financial Transaction'
|
tags 'User', 'Financial Transaction'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ describe 'User', type: :request do
|
||||||
# 401
|
# 401
|
||||||
it_handles_invalid_token_with_id(:financial_transaction)
|
it_handles_invalid_token_with_id(:financial_transaction)
|
||||||
# 403
|
# 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
|
# 404
|
||||||
response '404', 'financial transaction not found' do
|
response '404', 'financial transaction not found' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
|
|
|
@ -16,58 +16,13 @@ describe 'User', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
path '/user/group_order_articles' do
|
path '/user/group_order_articles' do
|
||||||
post 'group order article to create' do
|
get 'group order articles' 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
|
|
||||||
tags 'User', 'Order'
|
tags 'User', 'Order'
|
||||||
produces '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 }
|
||||||
response '200', 'success' do
|
response '200', 'success' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
meta: {
|
meta: {
|
||||||
|
@ -90,74 +45,65 @@ describe 'User', type: :request do
|
||||||
expect(data['group_order_articles'].first['id']).to eq(goa.id)
|
expect(data['group_order_articles'].first['id']).to eq(goa.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# responses 401 & 403
|
|
||||||
it_handles_invalid_token_and_scope
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
path '/user/group_order_articles/{id}' do
|
# response 401
|
||||||
patch 'summary: update a group order article (but delete if quantity and tolerance are zero)' do
|
it_handles_invalid_token
|
||||||
tags 'User', 'GroupOrderArticle'
|
|
||||||
|
# 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'
|
consumes 'application/json'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
parameter name: :id, in: :path, type: :string
|
|
||||||
|
|
||||||
parameter name: :group_order_article, in: :body, schema: {
|
parameter name: :group_order_article, in: :body, schema: {
|
||||||
type: :object,
|
type: :object,
|
||||||
|
description: 'group order article to create',
|
||||||
properties: {
|
properties: {
|
||||||
order_article_id: { type: :integer },
|
order_article_id: { type: :integer },
|
||||||
quantity: { 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
|
response '200', 'success' do
|
||||||
schema type: :object, properties: {
|
schema type: :object, properties: {
|
||||||
group_order_article_for_create: {
|
group_order_article_for_create: {
|
||||||
type: :object,
|
type: :object,
|
||||||
items: {
|
items: {
|
||||||
'$ref': '#/components/schemas/GroupOrderArticleForUpdate'
|
'$ref': '#/components/schemas/GroupOrderArticleForCreate'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
response 401, 'missing token' do
|
it_handles_invalid_token_with_id(:group_order_article)
|
||||||
let(:Authorization) { 'abc' }
|
|
||||||
schema '$ref' => '#/components/schemas/Error401'
|
|
||||||
run_test!
|
|
||||||
end
|
|
||||||
# 403
|
# 403
|
||||||
response 403, 'missing scope' do
|
# description: user has no ordergroup, is below minimum balance, self service is disabled, or missing scope
|
||||||
let(:api_scopes) { ['none'] }
|
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')
|
||||||
schema '$ref' => '#/components/schemas/Error403'
|
|
||||||
run_test!
|
|
||||||
end
|
|
||||||
# 404
|
# 404
|
||||||
response '404', 'group order article not found' do
|
response '404', 'order article not found in open orders' do
|
||||||
schema type: :object, properties: {
|
let(:group_order_article) { { order_article_id: 'invalid', quantity: 1, tolerance: 2 } }
|
||||||
group_order_article: {
|
schema '$ref' => '#/components/schemas/Error404'
|
||||||
type: :object,
|
|
||||||
items: {
|
|
||||||
'$ref': '#/components/schemas/GroupOrderArticle'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let(:id) { 'invalid' }
|
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
# 422
|
# 422
|
||||||
response '422', 'invalid parameter value' do
|
response '422', 'invalid parameter value or group order article already exists' do
|
||||||
let(:group_order_article) { { order_article_id: 'invalid', quantity: -5, tolerance: 'invalid' } }
|
let(:group_order_article) { { order_article_id: goa.order_article_id, quantity: 1, tolerance: 2 } }
|
||||||
schema '$ref' => '#/components/schemas/Error422'
|
schema '$ref' => '#/components/schemas/Error422'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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', 'GroupOrderArticle'
|
||||||
produces 'application/json'
|
produces 'application/json'
|
||||||
|
@ -180,13 +126,13 @@ describe 'User', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
response 401, 'missing token' do
|
response 401, 'not logged-in' do
|
||||||
let(:Authorization) { 'abc' }
|
let(:Authorization) { 'abc' }
|
||||||
schema '$ref' => '#/components/schemas/Error401'
|
schema '$ref' => '#/components/schemas/Error401'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
# 403
|
# 403
|
||||||
response 403, 'missing scope' do
|
response 403, 'user has no ordergroup or missing scope' do
|
||||||
let(:api_scopes) { ['none'] }
|
let(:api_scopes) { ['none'] }
|
||||||
schema '$ref' => '#/components/schemas/Error403'
|
schema '$ref' => '#/components/schemas/Error403'
|
||||||
run_test!
|
run_test!
|
||||||
|
@ -205,6 +151,69 @@ describe 'User', type: :request do
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
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
|
delete 'remove group order article' do
|
||||||
tags 'User', 'Order'
|
tags 'User', 'Order'
|
||||||
|
@ -228,32 +237,21 @@ describe 'User', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
response 401, 'missing token' do
|
response 401, 'not logged-in' do
|
||||||
let(:Authorization) { 'abc' }
|
let(:Authorization) { 'abc' }
|
||||||
schema '$ref' => '#/components/schemas/Error401'
|
schema '$ref' => '#/components/schemas/Error401'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
# 403
|
# 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'] }
|
let(:api_scopes) { ['none'] }
|
||||||
schema '$ref' => '#/components/schemas/Error403'
|
schema '$ref' => '#/components/schemas/Error403'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|
||||||
# 404
|
# 404
|
||||||
response '404', 'group order article not found' do
|
it_cannot_find_object('order article not found in open orders')
|
||||||
schema type: :object, properties: {
|
|
||||||
group_order_article: {
|
|
||||||
type: :object,
|
|
||||||
items: {
|
|
||||||
'$ref': '#/components/schemas/GroupOrderArticle'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let(:id) { 'invalid' }
|
|
||||||
run_test!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,29 +30,44 @@ module ApiHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.it_handles_invalid_scope
|
def self.it_handles_invalid_scope(description="missing scope")
|
||||||
context 'with invalid scope' do
|
context 'with invalid scope' do
|
||||||
let(:api_scopes) { ['none'] }
|
let(:api_scopes) { ['none'] }
|
||||||
|
|
||||||
response 403, 'missing scope' do
|
response 403, description do
|
||||||
schema '$ref' => '#/components/schemas/Error403'
|
schema '$ref' => '#/components/schemas/Error403'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.it_handles_invalid_scope_with_id(class_sym)
|
def self.it_handles_invalid_scope_with_id(class_sym, description)
|
||||||
context 'with invalid scope' do
|
context 'with invalid scope' do
|
||||||
let(:api_scopes) { ['none'] }
|
let(:api_scopes) { ['none'] }
|
||||||
let(:id) { create(class_sym).id }
|
let(:id) { create(class_sym).id }
|
||||||
|
response 403, description do
|
||||||
response 403, 'missing scope' do
|
|
||||||
schema '$ref' => '#/components/schemas/Error403'
|
schema '$ref' => '#/components/schemas/Error403'
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.it_cannot_find_object(description="not found")
|
||||||
|
# 404
|
||||||
|
response '404', description do
|
||||||
|
schema type: :object, properties: {
|
||||||
|
group_order_article: {
|
||||||
|
type: :object,
|
||||||
|
items: {
|
||||||
|
'$ref': '#/components/schemas/GroupOrderArticle'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let(:id) { 'invalid' }
|
||||||
|
run_test!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.it_handles_invalid_token_and_scope(*args)
|
def self.it_handles_invalid_token_and_scope(*args)
|
||||||
it_handles_invalid_token(*args)
|
it_handles_invalid_token(*args)
|
||||||
it_handles_invalid_scope(*args)
|
it_handles_invalid_scope(*args)
|
||||||
|
|
Loading…
Reference in a new issue