Allow the creation of guests associated to no group
All checks were successful
Check usage of free licenses / check-licenses (pull_request) Successful in 45s
Add copyright notice / copyright_notice (pull_request) Successful in 1m31s
Run unit tests / unit_tests (pull_request) Successful in 2m0s

This commit is contained in:
Manuel Bustillo 2024-12-08 13:10:49 +01:00
parent cbcb7b70e3
commit 83e36df14e
4 changed files with 5 additions and 4 deletions

View File

@ -5,7 +5,7 @@ require 'csv'
class GuestsController < ApplicationController
def index
render json: Guest.all.includes(:group)
.joins(:group)
.left_joins(:group)
.order('groups.name' => :asc, name: :asc)
.as_json(only: %i[id name status], include: { group: { only: %i[id name] } })
end

View File

@ -25,7 +25,7 @@
#
class Guest < ApplicationRecord
acts_as_tenant :wedding
belongs_to :group
belongs_to :group, optional: true
enum :status, {
considered: 0,

View File

@ -16,7 +16,7 @@ RSpec.describe Guest, type: :model do
end
end
it { should belong_to(:group) }
it { should belong_to(:group).optional }
describe 'scopes' do
describe '.potential' do

View File

@ -41,7 +41,7 @@ RSpec.describe 'guests', type: :request do
properties: {
guest: {
type: :object,
required: %i[name group_id status],
required: %i[name status],
properties: {
name: { type: :string },
group_id: { type: :string, format: :uuid },
@ -70,6 +70,7 @@ RSpec.describe 'guests', type: :request do
properties: {
guest: {
type: :object,
required: %i[name status],
properties: {
name: { type: :string },
group_id: { type: :string, format: :uuid },