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

Added safeguards for generating pool matches along with tests, updated two errors on about page, and added time saver to create middle school weights

This commit is contained in:
2023-01-24 22:56:22 +00:00
parent 1d0cff0e6f
commit c133a8b051
6 changed files with 131 additions and 23 deletions

View File

@@ -12,6 +12,83 @@ class TournamentTest < ActiveSupport::TestCase
assert_equal [:date, :name, :tournament_type, :address, :director, :director_email], tourney.errors.attribute_names
end
# Pool to bracket match_generation_error
test "Tournament pool to bracket match generation errors with less than two wrestlers" do
number_of_wrestlers=1
create_a_tournament_with_single_weight("Pool to bracket", number_of_wrestlers)
assert @tournament.match_generation_error != nil
end
test "Tournament pool to bracket match generation errors with more than 24 wrestlers" do
number_of_wrestlers=25
create_a_tournament_with_single_weight("Pool to bracket", number_of_wrestlers)
assert @tournament.match_generation_error != nil
end
test "Tournament pool to bracket no match generation errors with 24 wrestlers" do
number_of_wrestlers=24
create_a_tournament_with_single_weight("Pool to bracket", number_of_wrestlers)
assert @tournament.match_generation_error == nil
end
test "Tournament pool to bracket no match generation errors with 2 wrestlers" do
number_of_wrestlers=2
create_a_tournament_with_single_weight("Pool to bracket", number_of_wrestlers)
assert @tournament.match_generation_error == nil
end
# Modified 16 Man Double Elimination match_generation_error
test "TournamentModified 16 Man Double Elimination match generation errors with less than 12 wrestlers" do
number_of_wrestlers=11
create_a_tournament_with_single_weight("Modified 16 Man Double Elimination", number_of_wrestlers)
assert @tournament.match_generation_error != nil
end
test "Tournament Modified 16 Man Double Elimination match generation errors with more than 16 wrestlers" do
number_of_wrestlers=17
create_a_tournament_with_single_weight("Modified 16 Man Double Elimination", number_of_wrestlers)
assert @tournament.match_generation_error != nil
end
test "Tournament Modified 16 Man Double Elimination no match generation errors with 16 wrestlers" do
number_of_wrestlers=16
create_a_tournament_with_single_weight("Modified 16 Man Double Elimination", number_of_wrestlers)
assert @tournament.match_generation_error == nil
end
test "Tournament Modified 16 Man Double Elimination no match generation errors with 12 wrestlers" do
number_of_wrestlers=12
create_a_tournament_with_single_weight("Modified 16 Man Double Elimination", number_of_wrestlers)
assert @tournament.match_generation_error == nil
end
# Double Elimination match_generation_error
test "Tournament Double Elimination 1-8 match generation errors with less than 4 wrestlers" do
number_of_wrestlers=3
create_a_tournament_with_single_weight("Double Elimination 1-8", number_of_wrestlers)
assert @tournament.match_generation_error != nil
end
test "Tournament Double Elimination 1-8 match generation errors with more than 16 wrestlers" do
number_of_wrestlers=17
create_a_tournament_with_single_weight("Double Elimination 1-8", number_of_wrestlers)
assert @tournament.match_generation_error != nil
end
test "Tournament Double Elimination 1-8 no match generation errors with 16 wrestlers" do
number_of_wrestlers=16
create_a_tournament_with_single_weight("Double Elimination 1-8", number_of_wrestlers)
assert @tournament.match_generation_error == nil
end
test "Tournament Double Elimination 1-8 no match generation errors with 4 wrestlers" do
number_of_wrestlers=4
create_a_tournament_with_single_weight("Double Elimination 1-8", number_of_wrestlers)
assert @tournament.match_generation_error == nil
end
## End match_generation_error tests
test "Tournament create_pre_defined_weights High School Boys Weights" do
tournament = Tournament.find(1)
tournament.create_pre_defined_weights(Weight::HS_WEIGHT_CLASSES.split(","))
@@ -28,6 +105,14 @@ class TournamentTest < ActiveSupport::TestCase
end
end
test "Tournament create_pre_defined_weights Middle School Boys Weights" do
tournament = Tournament.find(1)
tournament.create_pre_defined_weights(Weight::MS_WEIGHT_CLASSES.split(","))
Weight::MS_WEIGHT_CLASSES.split(",").each do |weight|
assert tournament.weights.select{|w| w.max == weight.to_i}.count == 1
end
end
test "Tournament search_date_name returns results for all terms separately and non case sensitive" do
tournament = Tournament.new
tournament.name = "League Test Tournament D1"