mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-24 17:04: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:
@@ -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"
|
||||
|
||||
@@ -12,6 +12,28 @@ class ActiveSupport::TestCase
|
||||
fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
|
||||
def create_a_tournament_with_single_weight(tournament_type, number_of_wrestlers)
|
||||
@tournament = Tournament.new
|
||||
@tournament.name = "Test Tournament"
|
||||
@tournament.address = "some place"
|
||||
@tournament.director = "some guy"
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = tournament_type
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.is_public = true
|
||||
@tournament.save
|
||||
@school = School.new
|
||||
@school.name = "Test"
|
||||
@school.tournament_id = @tournament.id
|
||||
@school.save
|
||||
@weight = Weight.new
|
||||
@weight.max = 106
|
||||
@weight.tournament_id = @tournament.id
|
||||
@weight.save
|
||||
create_wrestlers_for_weight(@weight, @school, number_of_wrestlers, 1)
|
||||
return @tournament
|
||||
end
|
||||
|
||||
def create_pool_tournament_single_weight(number_of_wrestlers)
|
||||
@tournament = Tournament.new
|
||||
|
||||
Reference in New Issue
Block a user