diff --git a/app/models/suitability_record.rb b/app/models/suitability_record.rb index 8a6260ef7..b8bbc3bbe 100644 --- a/app/models/suitability_record.rb +++ b/app/models/suitability_record.rb @@ -39,6 +39,8 @@ def archived? class Email < ApplicationRecord self.table_name = "suitability_record_emails" + belongs_to :suitability_record + validates :value, presence: true validates :canonical, presence: true @@ -51,6 +53,8 @@ def value=(value) class Name < ApplicationRecord self.table_name = "suitability_record_names" + belongs_to :suitability_record + validates :value, presence: true end end diff --git a/spec/factories/suitability_records.rb b/spec/factories/suitability_records.rb index 01270dfac..2f0406d93 100644 --- a/spec/factories/suitability_records.rb +++ b/spec/factories/suitability_records.rb @@ -24,6 +24,8 @@ # FactoryBot.define do factory :suitability_record do + association :created_by, factory: :staff + note { Faker::Lorem.sentence } trait :archived do @@ -32,16 +34,16 @@ end end - factory :suitability_record_email do + factory :suitability_record_email, class: SuitabilityRecord::Email do association :suitability_record - value { Faker::Name.name } + value { Faker::Internet.email } + canonical { EmailAddress.canonical(value) } end - factory :suitability_record_name do + factory :suitability_record_name, class: SuitabilityRecord::Name do association :suitability_record - value { Faker::Internet.email } - canonical { EmailAddress.canonical(value) } + value { Faker::Name.name } end end