fix: article categories and 404 helper

This commit is contained in:
Philipp Rothmann 2022-12-12 11:30:09 +01:00
parent af6e06dfe7
commit ccff79b041
3 changed files with 11 additions and 212 deletions

View file

@ -9,8 +9,6 @@ describe 'Article Categories', type: :request do
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) { 10 }
let(:order_article) { create(:order, article_count: 1).order_articles.first }
let(:stock_article) { create(:stock_article) }
let(:stock_order_article) { create(:stock_order, article_ids: [stock_article.id]).order_articles.first }
@ -46,36 +44,11 @@ describe 'Article Categories', type: :request do
}
}
}
let(:id) { ArticleCategory.create(name: 'dairy').id }
run_test!
end
response '401', 'not logged in' do
schema type: :object, properties: {
article_categories: {
type: :array,
items: {
'$ref': '#/components/schemas/ArticleCategory'
}
}
}
let(:Authorization) { 'abc' }
let(:id) { ArticleCategory.create(name: 'dairy').id }
run_test!
end
response '404', 'article category not found' do
schema type: :object, properties: {
article_categories: {
type: :array,
items: {
'$ref': '#/components/schemas/ArticleCategory'
}
}
}
let(:id) { 'invalid' }
let(:id) { create(:article_category, name: 'dairy').id }
run_test!
end
it_handles_invalid_token_with_id(:article_category)
it_cannot_find_object
end
end
end

View file

@ -30,7 +30,7 @@ module ApiHelper
end
end
def self.it_handles_invalid_scope(description="missing scope")
def self.it_handles_invalid_scope(description = "missing scope")
context 'with invalid scope' do
let(:api_scopes) { ['none'] }
@ -45,6 +45,7 @@ module ApiHelper
context 'with invalid scope' do
let(:api_scopes) { ['none'] }
let(:id) { create(class_sym).id }
response 403, description do
schema '$ref' => '#/components/schemas/Error403'
run_test!
@ -52,18 +53,12 @@ module ApiHelper
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' }
def self.it_cannot_find_object(description = "not found")
let(:id) { 'invalid' }
response 404, description do
schema '$ref' => '#/components/schemas/Error404'
run_test!
end
end