Revert "Add test data for beerpong"

This reverts commit c708b86c35.
This commit is contained in:
Daniel Schädler 2025-03-02 12:20:29 +01:00
parent c708b86c35
commit 938ae92f59
3 changed files with 4 additions and 54 deletions

View File

@ -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
end

View File

@ -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
end

View File

@ -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