From 533929421bd17fefc40f365fd6df0fb414a57d9b Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Fri, 10 May 2019 13:07:59 +0200 Subject: [PATCH] Makes match_type configurable instead of only setting its state --- spec/factories/stages.rb | 7 +++---- spec/factories/tournaments.rb | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/factories/stages.rb b/spec/factories/stages.rb index a8e55b9..8348817 100644 --- a/spec/factories/stages.rb +++ b/spec/factories/stages.rb @@ -16,15 +16,14 @@ FactoryBot.define do factory :playoff_stage do level { rand(10) } transient do - match_state { :not_started } + match_type { :running_playoff_match } match_count { 4 } end after(:create) do |stage, evaluator| # match_count -1 automatically generates 2 ^ stage.level matches # (as this would be the amount of stages present in the real world) - stage.matches = create_list(:running_playoff_match, - evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count, - state: evaluator.match_state) + stage.matches = create_list(evaluator.match_type, + evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count) stage.matches.each_with_index do |match, i| match.position = i match.save diff --git a/spec/factories/tournaments.rb b/spec/factories/tournaments.rb index 92a5459..fae0fa6 100644 --- a/spec/factories/tournaments.rb +++ b/spec/factories/tournaments.rb @@ -24,7 +24,7 @@ FactoryBot.define do create(:playoff_stage, level: level, match_count: -1, - match_state: level == evaluator.stage_count ? :in_progress : :not_started) + match_type: level == evaluator.stage_count ? :running_playoff_match : :empty_prepared_playoff_match) } end