From 938ae92f59e71602efca7f5de416cf0a753937b3 Mon Sep 17 00:00:00 2001 From: Malaber Date: Sun, 2 Mar 2025 12:20:29 +0100 Subject: [PATCH] Revert "Add test data for beerpong" This reverts commit c708b86c35114e59f2331ef82d7c6aeca8b6f781. --- spec/factories/matches.rb | 24 +----------------------- spec/factories/stages.rb | 17 +++-------------- spec/factories/tournaments.rb | 17 ----------------- 3 files changed, 4 insertions(+), 54 deletions(-) diff --git a/spec/factories/matches.rb b/spec/factories/matches.rb index fecade1..6b9facd 100644 --- a/spec/factories/matches.rb +++ b/spec/factories/matches.rb @@ -4,18 +4,14 @@ FactoryBot.define do factory :playoff_match, aliases: [:match], class: Match do stage position { 0 } - factory :running_playoff_match do transient do match_scores_count { 2 } end - after(:create) do |match, evaluator| match.match_scores = create_list(:match_score, evaluator.match_scores_count) end - state { :in_progress } - factory :finished_playoff_match do state { :finished } end @@ -36,13 +32,11 @@ FactoryBot.define do transient do match_scores_count { 2 } end - after(:create) do |match, evaluator| match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 37) # random number generated by blapplications match.match_scores.first.points += 1 end - state { :finished } end end @@ -50,7 +44,6 @@ FactoryBot.define do factory :group_match, class: Match do group position { 0 } - factory :filled_group_match do transient do match_scores_count { 2 } @@ -73,25 +66,10 @@ FactoryBot.define do transient do match_scores_count { 2 } end - after(:create) do |match, evaluator| match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3) end - - state { :finished } - end - - factory :decided_group_match do - transient do - match_scores_count { 2 } - end - - after(:create) do |match, evaluator| - match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 37) - match.match_scores.first.points += 1 - end - state { :finished } end end -end \ No newline at end of file +end diff --git a/spec/factories/stages.rb b/spec/factories/stages.rb index 992eee1..8027cd7 100644 --- a/spec/factories/stages.rb +++ b/spec/factories/stages.rb @@ -3,7 +3,6 @@ FactoryBot.define do factory :stage do tournament - factory :group_stage do level { -1 } state { :in_progress } @@ -23,6 +22,8 @@ FactoryBot.define do 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(evaluator.match_type, evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count) stage.matches.each_with_index do |match, i| @@ -31,17 +32,5 @@ FactoryBot.define do stage.save! end end - - factory :decided_group_stage do - level { -1 } - state { :finished } - transient do - group_count { 8 } - match_factory { :decided_group_match } - end - after(:create) do |stage, evaluator| - stage.groups = create_list(:group, evaluator.group_count, match_factory: evaluator.match_factory) - end - end end -end \ No newline at end of file +end diff --git a/spec/factories/tournaments.rb b/spec/factories/tournaments.rb index 56746e5..9a8a7d3 100644 --- a/spec/factories/tournaments.rb +++ b/spec/factories/tournaments.rb @@ -60,22 +60,5 @@ FactoryBot.define do tournament.stages.concat create_list(:stage, evaluator.stage_count) end end - - factory :beerpong_tournament, parent: :tournament do - transient do - teams_count { 32 } - group_count { 8 } - match_factory { :group_match } - end - - after(:create) do |tournament, evaluator| - tournament.stages << create(:group_stage, - match_factory: evaluator.match_factory, - group_count: evaluator.group_count) - tournament.teams = create_list(:team, evaluator.teams_count, tournament: tournament) - tournament.playoff_teams_amount = 16 - tournament.save! - end - end end end