wedding-planner/spec/requests/groups_spec.rb

103 lines
3.1 KiB
Ruby
Raw Normal View History

2024-11-15 17:29:56 +00:00
# Copyright (C) 2024 Manuel Bustillo
2024-11-15 18:28:45 +01:00
require 'swagger_helper'
RSpec.describe 'groups', type: :request do
path '/{slug}/groups' do
2024-11-15 18:28:45 +01:00
get('list groups') do
tags 'Groups'
produces 'application/json'
parameter Swagger::Schema::SLUG
2024-11-15 18:28:45 +01:00
response(200, 'successful') do
schema type: :array,
items: {
type: :object,
required: %i[id name icon parent_id color total considered invited confirmed declined tentative],
properties: {
id: { type: :string, format: :uuid, required: true },
name: { type: :string },
icon: { type: :string, example: 'pi pi-crown', description: 'The CSS classes used by the icon' },
parent_id: { type: :string, format: :uuid },
color: { type: :string, pattern: '^#(?:[0-9a-fA-F]{3}){1,2}$' },
total: { type: :integer, minimum: 0, description: 'Total number of guests in any status' },
considered: { type: :integer, minimum: 0 },
invited: { type: :integer, minimum: 0 },
confirmed: { type: :integer, minimum: 0 },
declined: { type: :integer, minimum: 0 },
tentative: { type: :integer, minimum: 0 }
}
}
xit
2024-11-15 18:28:45 +01:00
end
regular_api_responses
2024-11-15 18:28:45 +01:00
end
post('create group') do
tags 'Groups'
consumes 'application/json'
produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :body, in: :body, schema: {
type: :object,
required: %i[group],
properties: {
group: {
type: :object,
required: %i[name],
properties: Swagger::Schema::GROUP
}
}
}
response(201, 'created') do
schema type: :object, properties: {
id: { type: :string, format: :uuid, required: true },
**Swagger::Schema::GROUP
}
xit
end
regular_api_responses
end
path '/{slug}/groups/{id}' do
put('update group') do
tags 'Groups'
consumes 'application/json'
produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :id, in: :path, type: :string, format: :uuid
parameter name: :body, in: :body, schema: {
type: :object,
required: %i[group],
properties: {
group: {
type: :object,
required: %i[name],
properties: Swagger::Schema::GROUP
}
}
}
response(200, 'updated') do
schema type: :object, properties: {
id: { type: :string, format: :uuid, required: true },
**Swagger::Schema::GROUP
}
xit
end
regular_api_responses
end
delete('delete group') do
tags 'Groups'
produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :id, in: :path, type: :string, format: :uuid
response_empty_200
regular_api_responses
end
end
2024-11-15 18:28:45 +01:00
end
end