wedding-planner/spec/models/guest_spec.rb
Manuel Bustillo 55e6cfcd36
Some checks failed
Check usage of free licenses / check-licenses (pull_request) Failing after 1m53s
Run unit tests / unit_tests (pull_request) Failing after 3m11s
Add copyright notice / copyright_notice (pull_request) Successful in 3m16s
Fix order of Ruby's magic string comment and Copyright assignment
2024-12-28 18:37:47 +01:00

40 lines
1.0 KiB
Ruby

# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Guest do
describe 'validations' do
subject(:guest) { build(:guest) }
it { is_expected.to validate_presence_of(:name) }
it do
expect(guest).to define_enum_for(:status).with_values(
considered: 0,
invited: 10,
confirmed: 20,
declined: 30,
tentative: 40
)
end
end
it { is_expected.to belong_to(:group).optional }
describe 'scopes' do
describe '.potential' do
it 'returns guests that are not declined or considered' do
_declined_guest = create(:guest, status: :declined)
_considered_guest = create(:guest, status: :considered)
invited_guest = create(:guest, status: :invited)
confirmed_guest = create(:guest, status: :confirmed)
tentative_guest = create(:guest, status: :tentative)
expect(described_class.potential).to contain_exactly(invited_guest, confirmed_guest, tentative_guest)
end
end
end
end