Skip to content

Commit

Permalink
Fix suitability record factory
Browse files Browse the repository at this point in the history
This fixes issues with the factories related to suitability records.
  • Loading branch information
thomasleese committed Jul 16, 2024
1 parent 7f88418 commit 6a29296
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/models/suitability_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
12 changes: 7 additions & 5 deletions spec/factories/suitability_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#
FactoryBot.define do
factory :suitability_record do
association :created_by, factory: :staff

note { Faker::Lorem.sentence }

trait :archived do
Expand All @@ -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

0 comments on commit 6a29296

Please sign in to comment.