refactor: extract id parameter

This commit is contained in:
Philipp Rothmann 2022-12-12 15:54:53 +01:00
parent 57593db96d
commit 4c0a7ae938
9 changed files with 17 additions and 13 deletions

View file

@ -33,7 +33,7 @@ describe 'Article Categories', type: :request do
get 'find article category by id' do
tags 'Category'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
response '200', 'article category found' do
schema type: :object, properties: {

View file

@ -35,7 +35,7 @@ describe 'Financial Transaction Classes', type: :request do
get 'Retrieves a financial transaction class' do
tags 'Category'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
response '200', 'financial transaction class found' do
schema type: :object, properties: {

View file

@ -33,7 +33,7 @@ describe 'Financial Transaction types', type: :request do
get 'find financial transaction type by id' do
tags 'Category'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
response '200', 'financial transaction type found' do
schema type: :object, properties: {

View file

@ -37,7 +37,7 @@ describe 'Financial Transaction', type: :request do
get 'Retrieves a financial transaction ' do
tags 'Financial Transaction'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
response '200', 'financial transaction found' do
schema type: :object, properties: {

View file

@ -105,7 +105,7 @@ describe 'Order Articles', type: :request do
get 'order articles' do
tags 'Order'
produces 'application/json'
parameter name: 'id', in: :path, type: :integer, minimum: 1, required: true
id_url_param
let(:api_scopes) { ['orders:read', 'orders:write'] }
response '200', 'success' do

View file

@ -39,7 +39,8 @@ describe 'Orders', type: :request do
get 'Order' do
tags 'Order'
produces 'application/json'
parameter name: 'id', in: :path, type: :integer, minimum: 1, required: true
id_url_param
let(:order) { create(:order) }
let(:id) { order.id }

View file

@ -88,7 +88,7 @@ describe 'User', type: :request do
get 'find financial transaction by id' do
tags 'User', 'Financial Transaction'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
response '200', 'success' do
schema type: :object, properties: {

View file

@ -107,9 +107,8 @@ describe 'User', type: :request do
get 'find group order article by id' do
tags 'User', 'GroupOrderArticle'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
let(:id) { goa.id }
response '200', 'success' do
schema type: :object, properties: {
group_order_article: {
@ -119,6 +118,7 @@ describe 'User', type: :request do
}
}
}
let(:id) { goa.id }
run_test! do |response|
data = JSON.parse(response.body)
expect(data['group_order_article']['id']).to eq(goa.id)
@ -155,7 +155,7 @@ describe 'User', type: :request do
tags 'User', 'GroupOrderArticle'
consumes 'application/json'
produces 'application/json'
parameter name: :id, in: :path, type: :string
id_url_param
parameter name: :group_order_article, in: :body, schema: {
type: :object,
@ -219,11 +219,9 @@ describe 'User', type: :request do
tags 'User', 'Order'
consumes 'application/json'
produces 'application/json'
id_url_param
let(:api_scopes) { ['group_orders:user'] }
parameter name: :id, in: :path, type: :string
let(:id) { goa.id }
response '200', 'success' do
schema type: :object, properties: {
group_order_article: {
@ -233,6 +231,7 @@ describe 'User', type: :request do
}
}
}
let(:id) { goa.id }
run_test!
end

View file

@ -67,5 +67,9 @@ module ApiHelper
it_handles_invalid_token(*args)
it_handles_invalid_scope(*args)
end
def self.id_url_param
parameter name: :id, in: :path, type: :integer, required: true
end
end
end