76 lines
1.9 KiB
Ruby
76 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
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
|
|
end
|
|
|
|
factory :single_team_match do
|
|
state { :single_team }
|
|
after(:create) do |match|
|
|
match.match_scores = [create(:match_score, points: 0)]
|
|
end
|
|
end
|
|
|
|
factory :empty_prepared_playoff_match do
|
|
state { :not_ready }
|
|
end
|
|
|
|
factory :decided_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, points: 37)
|
|
# random number generated by blapplications
|
|
match.match_scores.first.points += 1
|
|
end
|
|
state { :finished }
|
|
end
|
|
end
|
|
|
|
factory :group_match, class: Match do
|
|
group
|
|
position { 0 }
|
|
factory :filled_group_match do
|
|
transient do
|
|
match_scores_count { 2 }
|
|
end
|
|
|
|
factory :running_group_match do
|
|
state { :in_progress }
|
|
end
|
|
|
|
after(:create) do |match, evaluator|
|
|
match.match_scores = create_list(:match_score, evaluator.match_scores_count)
|
|
end
|
|
|
|
factory :finished_group_match do
|
|
state { :finished }
|
|
end
|
|
end
|
|
|
|
factory :undecided_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: 3)
|
|
end
|
|
state { :finished }
|
|
end
|
|
end
|
|
end
|