Define an endpoint to destroy guests

This commit is contained in:
Manuel Bustillo 2024-11-17 18:24:43 +01:00
parent 7bdfb4f789
commit 7542c6361c
4 changed files with 17 additions and 1 deletions

View File

@ -19,4 +19,9 @@ class GuestsController < ApplicationController
Guest.find(params[:id]).update!(params.require(:guest).permit(:name, :status))
render json: {}, status: :ok
end
def destroy
Guest.find(params[:id]).destroy!
render json: {}, status: :ok
end
end

View File

@ -37,6 +37,8 @@ class Guest < ApplicationRecord
after_save :recalculate_simulations, if: :saved_change_to_status?
has_many :seats, dependent: :delete_all
private
def recalculate_simulations

View File

@ -4,7 +4,7 @@ Rails.application.routes.draw do
mount Rswag::Ui::Engine => '/api-docs'
mount Rswag::Api::Engine => '/api-docs'
resources :groups, only: :index
resources :guests, only: %i[index create update] do
resources :guests, only: %i[index create update destroy] do
post :bulk_update, on: :collection
end
resources :expenses, only: %i[index update] do

View File

@ -77,5 +77,14 @@ RSpec.describe 'guests', type: :request do
response_422
response_404
end
delete('delete guest') do
tags 'Guests'
produces 'application/json'
parameter name: 'id', in: :path, type: :string, format: :uuid
response_empty_200
response_404
end
end
end