1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added a sort by bout number for assign_next_match

This commit is contained in:
2022-01-19 03:28:16 +00:00
parent f0e8c99b9f
commit d42b683f67
13 changed files with 199 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ class PoolToBracketAdvancementTest < ActionDispatch::IntegrationTest
match.winner_id = match.w2
end
match.finished = 1
match.win_type = "Decision"
match.score = "2-1"
match.save
end

View File

@@ -1,7 +1,120 @@
require 'test_helper'
class MatchTest < ActiveSupport::TestCase
test "the truth" do
assert true
test "Match should not be valid if win type is a pin and a score is provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "Pin"
match.score = "0-0"
match.save
assert !match.valid?
end
test "Match should not be valid if win type is a pin and an incorrect time is provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "Pin"
match.score = ":03"
match.save
assert !match.valid?
end
test "Match should be valid if win type is a pin and a correct time is provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "Pin"
match.score = "0:03"
match.save
assert match.valid?
end
test "Match should be valid if win type is a pin and a correct time is provided with an extra 0" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "Pin"
match.score = "00:03"
match.save
assert match.valid?
end
test "Match should be valid if win type is a decision and a correct score is provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "Decision"
match.score = "1-0"
match.save
assert match.valid?
end
test "Match should not be valid if win type is a decision and a time is provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "Decision"
match.score = "1:00"
match.save
assert !match.valid?
end
test "Match should not be valid if win type is a bye and a score is provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "BYE"
match.score = "1:00"
match.save
assert !match.valid?
end
test "Match should be valid if win type is a bye and a score is not provided" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "BYE"
match.score = ""
match.save
assert match.valid?
end
test "Match should not be valid if an incorrect win type is given" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.winner_id = match.w1
match.finished = 1
match.win_type = "TEST"
match.save
assert !match.valid?
end
test "Match should not be valid if an incorrect bracket position is given" do
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}
match = matches.first
match.bracket_position = "TEST"
match.save
assert !match.valid?
end
end

View File

@@ -191,7 +191,7 @@ class ActiveSupport::TestCase
def end_match(match,winner)
match.win_type = "Decision"
match.score = 1-0
match.score = "1-0"
save_match(match,winner)
end