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