2024-12-28 18:07:22 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-11-16 09:23:51 +00:00
|
|
|
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
|
2024-11-16 10:22:10 +01:00
|
|
|
require 'swagger_helper'
|
|
|
|
|
2024-12-28 18:07:22 +01:00
|
|
|
RSpec.describe 'expenses' do
|
2024-11-30 19:57:08 +01:00
|
|
|
path '/{slug}/expenses' do
|
2024-11-16 10:22:10 +01:00
|
|
|
get('list expenses') do
|
|
|
|
tags 'Expenses'
|
|
|
|
produces 'application/json'
|
2024-11-30 19:57:08 +01:00
|
|
|
parameter Swagger::Schema::SLUG
|
|
|
|
|
2024-11-16 10:22:10 +01:00
|
|
|
response(200, 'successful') do
|
|
|
|
schema type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[id name amount pricing_type],
|
|
|
|
properties: {
|
|
|
|
id: { type: :string, format: :uuid },
|
2024-12-09 19:28:32 +01:00
|
|
|
**Swagger::Schema::EXPENSE
|
2024-11-16 10:22:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xit
|
|
|
|
end
|
2024-11-30 14:24:02 +01:00
|
|
|
regular_api_responses
|
2024-11-16 10:22:10 +01:00
|
|
|
end
|
2024-12-09 19:28:32 +01:00
|
|
|
|
|
|
|
post 'create expense' do
|
|
|
|
tags 'Expenses'
|
|
|
|
consumes 'application/json'
|
|
|
|
produces 'application/json'
|
|
|
|
parameter Swagger::Schema::SLUG
|
|
|
|
parameter name: :body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[expense],
|
|
|
|
properties: {
|
|
|
|
expense: {
|
|
|
|
type: :object,
|
|
|
|
required: %i[name amount pricing_type],
|
|
|
|
properties: Swagger::Schema::EXPENSE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-28 18:07:22 +01:00
|
|
|
response_empty201
|
|
|
|
response422
|
2024-12-09 19:28:32 +01:00
|
|
|
regular_api_responses
|
|
|
|
end
|
2024-11-16 10:22:10 +01:00
|
|
|
end
|
|
|
|
|
2024-11-30 19:57:08 +01:00
|
|
|
path '/{slug}/expenses/{id}' do
|
2024-11-16 10:22:10 +01:00
|
|
|
patch('update expense') do
|
|
|
|
tags 'Expenses'
|
|
|
|
consumes 'application/json'
|
|
|
|
produces 'application/json'
|
2024-11-30 19:57:08 +01:00
|
|
|
parameter Swagger::Schema::SLUG
|
2024-11-16 10:22:10 +01:00
|
|
|
parameter name: 'id', in: :path, type: :string, format: :uuid, description: 'id'
|
|
|
|
parameter name: :body, in: :body, schema: {
|
|
|
|
type: :object,
|
2024-12-09 19:28:32 +01:00
|
|
|
properties: Swagger::Schema::EXPENSE
|
2024-11-16 10:22:10 +01:00
|
|
|
}
|
|
|
|
|
2024-12-28 18:07:22 +01:00
|
|
|
response_empty200
|
|
|
|
response422
|
|
|
|
response404
|
2024-11-30 14:24:02 +01:00
|
|
|
regular_api_responses
|
2024-11-16 10:22:10 +01:00
|
|
|
end
|
2024-12-09 19:28:32 +01:00
|
|
|
|
|
|
|
delete('delete expense') do
|
|
|
|
tags 'Expenses'
|
|
|
|
produces 'application/json'
|
|
|
|
parameter Swagger::Schema::SLUG
|
|
|
|
parameter Swagger::Schema::ID
|
2024-12-28 18:07:22 +01:00
|
|
|
response_empty200
|
|
|
|
response404
|
2024-12-09 19:28:32 +01:00
|
|
|
regular_api_responses
|
|
|
|
end
|
2024-11-16 10:22:10 +01:00
|
|
|
end
|
|
|
|
end
|