From 55f16563282e962c46dcc84a557eacd029e5f631 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Thu, 9 May 2019 16:14:27 +0200 Subject: [PATCH] Manually create the list of stages to assign stage levels correctly --- spec/factories/tournaments.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/factories/tournaments.rb b/spec/factories/tournaments.rb index 942abad..8c40054 100644 --- a/spec/factories/tournaments.rb +++ b/spec/factories/tournaments.rb @@ -17,7 +17,10 @@ FactoryBot.define do stage_count { 1 } end after(:create) do |tournament, evaluator| - tournament.stages = create_list(:stage, evaluator.stage_count) + # this is basically a manual create_list as we need to count up the level of the stage + tournament.stages.concat 1..evaluator.stage_count.map do |level| + create(:playoff_stage, level: level, match_count: -1) + end end factory :group_stage_tournament do