Refine guest controller #140

Merged
bustikiller merged 1 commits from refine-guest-controller into main 2024-11-17 19:06:00 +00:00
2 changed files with 9 additions and 2 deletions

View File

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

View File

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