Refine guest controller
All checks were successful
Check usage of free licenses / check-licenses (pull_request) Successful in 42s
Add copyright notice / copyright_notice (pull_request) Successful in 1m27s
Run unit tests / unit_tests (pull_request) Successful in 3m31s

This commit is contained in:
Manuel Bustillo 2024-11-17 20:01:23 +01:00
parent 7bdfb4f789
commit cb0e387c3a
2 changed files with 14 additions and 2 deletions

View File

@ -11,12 +11,23 @@ class GuestsController < ApplicationController
end
def create
Guest.create!(params.require(:guest).permit(:name, :group_id, :status))
Guest.create!(guest_params)
render json: {}, status: :created
end
def update
Guest.find(params[:id]).update!(params.require(:guest).permit(:name, :status))
Guest.find(params[:id]).update!(guest_params)
render json: {}, status: :ok
end
def destroy
Guest.find(params[:id]).destroy!
render json: {}, status: :ok
end
private
def guest_params
params.require(:guest).permit(:name, :group_id, :status)
end
end

View File

@ -67,6 +67,7 @@ RSpec.describe 'guests', type: :request do
type: :object,
properties: {
name: { type: :string },
group_id: { type: :string, format: :uuid },
status: { type: :string, enum: Guest.statuses.keys }
}
}