Add multiple factories

This commit is contained in:
Daniel Schädler 2019-04-27 22:27:38 +02:00
parent 6811c9e7eb
commit 3fc344249d
3 changed files with 24 additions and 0 deletions

View File

@ -2,7 +2,15 @@
FactoryBot.define do
factory :group do
transient do
match_count { 4 }
end
sequence(:number)
stage
after(:create) do |group, evaluator|
create_list(:group_match, evaluator.match_count, group: group)
end
end
end

View File

@ -3,5 +3,14 @@
FactoryBot.define do
factory :stage do
tournament
factory :group_stage do
level { -1 }
transient do
group_count { 4 }
end
after(:create) do |stage, evaluator|
stage.groups = create_list(:group, evaluator.group_count)
end
end
end
end

View File

@ -11,6 +11,7 @@ FactoryBot.define do
after(:create) do |tournament, evaluator|
tournament.teams = create_list(:team, evaluator.teams_count, tournament: tournament)
end
factory :stage_tournament do
transient do
stage_count { 1 }
@ -19,5 +20,11 @@ FactoryBot.define do
tournament.stages = create_list(:stage, evaluator.stage_count)
end
end
factory :group_stage_tournament do
after(:create) do |tournament, _evaluator|
tournament.stages = create_list(:group_stage, 1)
end
end
end
end