foodsoft/spec/requests/api/article_categories_spec.rb

55 lines
1.5 KiB
Ruby
Raw Normal View History

2022-11-21 17:06:51 +01:00
require 'swagger_helper'
describe 'Article Categories', type: :request do
include ApiHelper
path '/article_categories' do
get 'article categories' do
tags 'Category'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
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 }
2022-11-21 17:06:51 +01:00
response '200', 'success' do
schema type: :object, properties: {
article_categories: {
type: :array,
items: {
'$ref': '#/components/schemas/ArticleCategory'
}
}
}
2022-11-25 13:55:21 +01:00
run_test!
end
it_handles_invalid_token
end
end
path '/article_categories/{id}' do
get 'find article category by id' do
2022-11-25 13:55:21 +01:00
tags 'Category'
produces 'application/json'
2022-12-12 15:54:53 +01:00
id_url_param
2022-11-25 13:55:21 +01:00
response '200', 'article category found' do
schema type: :object, properties: {
article_categories: {
type: :array,
items: {
'$ref': '#/components/schemas/ArticleCategory'
}
}
}
2022-12-12 11:30:09 +01:00
let(:id) { create(:article_category, name: 'dairy').id }
2022-11-25 13:55:21 +01:00
run_test!
end
2022-12-12 11:30:09 +01:00
it_handles_invalid_token_with_id(:article_category)
it_cannot_find_object
2022-11-21 17:06:51 +01:00
end
end
end