wip: article_categories spec
This commit is contained in:
parent
1020035cfe
commit
3b7eae694a
3 changed files with 86 additions and 1 deletions
40
spec/requests/api/article_categories_spec.rb
Normal file
40
spec/requests/api/article_categories_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
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: :page, in: :query, schema: { '$ref' => '#/components/schemas/page' }
|
||||
parameter name: :per_page, in: :query, schema: { '$ref' => '#/components/schemas/per_page' }
|
||||
|
||||
let(:api_scopes) { ['orders:read'] }
|
||||
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 }
|
||||
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
article_categories: {
|
||||
type: :array,
|
||||
items: {
|
||||
'$ref': '#/components/schemas/ArticleCategory'
|
||||
}
|
||||
},
|
||||
meta: {
|
||||
'$ref': '#/components/schemas/Meta'
|
||||
}
|
||||
}
|
||||
|
||||
let(:page) { 0 }
|
||||
let(:per_page) { 20 }
|
||||
run_test!
|
||||
end
|
||||
|
||||
it_handles_invalid_token_and_scope
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,7 +7,6 @@ describe 'Navigation', type: :request do
|
|||
get 'navigation' do
|
||||
tags 'General'
|
||||
produces 'application/json'
|
||||
let(:api_scopes) { ['config:user'] }
|
||||
|
||||
response '200', 'success' do
|
||||
schema type: :object, properties: {
|
||||
|
|
|
@ -24,6 +24,52 @@ RSpec.configure do |config|
|
|||
paths: {},
|
||||
components: {
|
||||
schemas: {
|
||||
page: {
|
||||
type: :integer,
|
||||
description: 'page number',
|
||||
minimum: 0,
|
||||
default: 0
|
||||
},
|
||||
per_page: {
|
||||
type: :integer,
|
||||
description: 'items per page',
|
||||
minimum: 0,
|
||||
default: 20
|
||||
},
|
||||
ArticleCategory: {
|
||||
type: :object,
|
||||
properties: {
|
||||
id: {
|
||||
type: :integer
|
||||
},
|
||||
name: {
|
||||
type: :string
|
||||
}
|
||||
},
|
||||
required: %w[id name]
|
||||
},
|
||||
Meta: {
|
||||
type: :object,
|
||||
properties: {
|
||||
page: {
|
||||
type: :integer,
|
||||
description: 'page number of the returned collection'
|
||||
},
|
||||
per_page: {
|
||||
type: :integer,
|
||||
description: 'number of items per page'
|
||||
},
|
||||
total_pages: {
|
||||
type: :integer,
|
||||
description: 'total number of pages'
|
||||
},
|
||||
total_count: {
|
||||
type: :integer,
|
||||
description: 'total number of items in the collection'
|
||||
},
|
||||
required: %w[page per_page total_pages total_count]
|
||||
}
|
||||
},
|
||||
Navigation: {
|
||||
type: :array,
|
||||
items: {
|
||||
|
|
Loading…
Reference in a new issue