2020-04-30 13:49:15 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
2020-05-25 09:04:54 -07:00
|
|
|
factory :list do
|
2020-04-30 13:49:15 -07:00
|
|
|
sequence(:display_name) { |i| "#{Faker::Internet.username(specifier: 0..12, separators: %w[_])}#{i}" }
|
|
|
|
user { FactoryBot.build(:user) }
|
2020-04-30 15:05:41 -07:00
|
|
|
|
|
|
|
transient do
|
|
|
|
members { [] }
|
|
|
|
end
|
|
|
|
|
2020-05-25 09:04:54 -07:00
|
|
|
after(:create) do |list, evaluator|
|
2020-04-30 15:05:41 -07:00
|
|
|
evaluator.members.each do |member|
|
2020-05-25 09:04:54 -07:00
|
|
|
ListMember.create(list_id: list.id, user_id: member.id)
|
2020-04-30 15:05:41 -07:00
|
|
|
end
|
|
|
|
end
|
2020-04-30 13:49:15 -07:00
|
|
|
end
|
|
|
|
end
|