Include confirmation status
All checks were successful
Run unit tests / unit_tests (pull_request) Successful in 2m39s

This commit is contained in:
Manuel Bustillo 2024-08-11 19:24:24 +02:00
parent c177131672
commit cb42b86136
5 changed files with 22 additions and 3 deletions

View File

@ -1,6 +1,14 @@
class Guest < ApplicationRecord
acts_as_taggable_on :affinity_groups, :unbreakable_bonds
belongs_to :group
enum status: {
considered: 0,
invited: 10,
confirmed: 20,
declined: 30
}
def full_name
"#{first_name} #{last_name}"
end

View File

@ -1,7 +1,7 @@
class SerializableGuest < JSONAPI::Serializable::Resource
type 'guest'
attributes :id, :email, :group_id
attributes :id, :email, :group_id, :status
attribute :name do
"#{@object.first_name} #{@object.last_name}"
@ -10,4 +10,8 @@ class SerializableGuest < JSONAPI::Serializable::Resource
attribute :group_name do
@object.group.name
end
attribute :status do
@object.status.capitalize
end
end

View File

@ -0,0 +1,5 @@
class AddStatusToGuest < ActiveRecord::Migration[7.1]
def change
add_column :guests, :status, :integer, default: 0
end
end

3
db/schema.rb generated
View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_08_11_154115) do
ActiveRecord::Schema[7.1].define(version: 2024_08_11_170021) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -45,6 +45,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_11_154115) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "group_id", null: false
t.integer "status", default: 0
t.index ["group_id"], name: "index_guests_on_group_id"
end

View File

@ -60,6 +60,7 @@ NUMBER_OF_GUESTS.times do
last_name: Faker::Name.last_name,
email: Faker::Internet.email,
phone: Faker::PhoneNumber.cell_phone,
group: groups.sample
group: groups.sample,
status: Guest.statuses.keys.sample
)
end