refactor: pagination param

This commit is contained in:
Philipp Rothmann 2023-01-02 13:01:33 +01:00
parent f8c9aaf35a
commit 18358484ba
8 changed files with 13 additions and 17 deletions

View file

@ -7,8 +7,7 @@ describe 'Article Categories', type: :request 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
pagination_param
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 }

View file

@ -7,8 +7,7 @@ describe 'Financial Transaction Classes', type: :request do
get 'financial transaction classes' 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
pagination_param
let(:financial_transaction_class) { create(:financial_transaction_class) }
response '200', 'success' do

View file

@ -7,8 +7,7 @@ describe 'Financial Transaction types', type: :request do
get 'financial transaction types' 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
pagination_param
let(:financial_transaction_type) { create(:financial_transaction_type) }
response '200', 'success' do
schema type: :object, properties: {

View file

@ -11,8 +11,7 @@ describe 'Financial Transaction', type: :request do
get 'financial transactions' do
tags 'Financial Transaction'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
pagination_param
response '200', 'success' do
schema type: :object, properties: {

View file

@ -8,9 +8,7 @@ describe 'Orders', type: :request do
get 'orders' do
tags 'Order'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
pagination_param
let(:order) { create(:order) }
response '200', 'success' do

View file

@ -59,9 +59,7 @@ describe 'User', type: :request do
get "financial transactions of the member's ordergroup" do
tags 'User', 'Financial Transaction'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
pagination_param
response '200', 'success' do
schema type: :object, properties: {

View file

@ -19,8 +19,7 @@ describe 'User', type: :request do
get 'group order articles' do
tags 'User', 'Order'
produces 'application/json'
parameter name: "per_page", in: :query, type: :integer, required: false
parameter name: "page", in: :query, type: :integer, required: false
pagination_param
q_ordered_url_param
response '200', 'success' do

View file

@ -71,8 +71,13 @@ module ApiHelper
parameter name: :id, in: :path, type: :integer, required: true
end
def self.pagination_param
parameter name: :per_page, in: :query, type: :integer, required: false
parameter name: :page, in: :query, type: :integer, required: false
end
def self.q_ordered_url_param
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",
schema: { '$ref' => '#/components/schemas/q_ordered' }
end