diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 67d8e8c..c870870 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -128,17 +128,19 @@ end
end
end
- def pool_to_bracket_weights_with_too_many_wrestlers
- if self.tournament_type == "Pool to bracket"
- weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 24}
- if weightsWithTooManyWrestlers.size < 1
- return nil
- else
- return weightsWithTooManyWrestlers
- end
- else
- nil
- end
+ def pool_to_bracket_number_of_wrestlers
+ error_string = ""
+ if self.tournament_type.include? "Pool to bracket"
+ weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 24}
+ weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 2}
+ weights_with_too_many_wrestlers.each do |weight|
+ error_string = error_string + " The weight class #{weight.max} has more than 24 wrestlers."
+ end
+ weight_with_too_few_wrestlers.each do |weight|
+ error_string = error_string + " The weight class #{weight.max} has less than 2 wrestlers."
+ end
+ end
+ return error_string
end
def modified_sixteen_man_number_of_wrestlers
@@ -158,7 +160,7 @@ end
def double_elim_number_of_wrestlers
error_string = ""
- if self.tournament_type == "Double Elimination 1-6"
+ if self.tournament_type == "Double Elimination 1-6" or self.tournament_type == "Double Elimination 1-8"
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 4}
weights_with_too_many_wrestlers.each do |weight|
@@ -174,14 +176,11 @@ end
def match_generation_error
error_string = "There is a tournament error."
modified_sixteen_man_error = modified_sixteen_man_number_of_wrestlers
- double_elim_error = double_elim_number_of_wrestlers
- if pool_to_bracket_weights_with_too_many_wrestlers != nil
- error_string = error_string + " The following weights have too many wrestlers "
- pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
- error_string = error_string + "#{w.max} "
- end
- return error_string
- elsif modified_sixteen_man_error.length > 0
+ double_elim_error = double_elim_number_of_wrestlers
+ pool_to_bracket_error = pool_to_bracket_number_of_wrestlers
+ if pool_to_bracket_error.length > 0
+ return error_string + pool_to_bracket_error
+ elsif modified_sixteen_man_error.length > 0
return error_string + modified_sixteen_man_error
elsif double_elim_error.length > 0
return error_string + double_elim_error
diff --git a/app/models/weight.rb b/app/models/weight.rb
index e306e5f..2e9528d 100644
--- a/app/models/weight.rb
+++ b/app/models/weight.rb
@@ -12,6 +12,7 @@ class Weight < ActiveRecord::Base
# tournament model runs the code via method create_pre_defined_weights
HS_WEIGHT_CLASSES = "106,113,120,126,132,138,144,150,157,165,175,190,215,285"
HS_GIRLS_WEIGHT_CLASSES = "100,105,110,115,120,125,130,135,140,145,155,170,190,235"
+ MS_WEIGHT_CLASSES = "80,86,92,98,104,110,116,122,128,134,142,150,160,172,205,245"
before_destroy do
self.tournament.destroy_all_matches
diff --git a/app/views/layouts/_tournament-navbar.html.erb b/app/views/layouts/_tournament-navbar.html.erb
index 99edca5..5915715 100644
--- a/app/views/layouts/_tournament-navbar.html.erb
+++ b/app/views/layouts/_tournament-navbar.html.erb
@@ -45,6 +45,7 @@
Time Savers
<%= link_to "Create Boys High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %>
<%= link_to "Create Girls High School Weights (101-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_GIRLS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %>
+ <%= link_to "Create Boys Middle School Weights (80-245)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::MS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %>
Tournament Actions
<%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", :method => :put %>
<%= link_to "Generate Brackets" , "/tournaments/#{@tournament.id}/generate_matches", data: { confirm: 'Are you sure? This will delete all current matches.' } %>
diff --git a/app/views/static_pages/about.html.erb b/app/views/static_pages/about.html.erb
index bd1dc8e..ae3032c 100644
--- a/app/views/static_pages/about.html.erb
+++ b/app/views/static_pages/about.html.erb
@@ -36,7 +36,7 @@
Most wins by tech fall
Most wins by major
Most points scored in decisions
- Quickest pin
+ Total pin time accumulation
Coin flip
If three wrestlers are tied, they will be put through this sequence until two wrestlers are left. Once two wrestlers are left, the pool runner up will be decided by head to head.
@@ -53,8 +53,8 @@
See placement points below (based on the largest bracket of the tournament)
Pool Types
- - Single pool round robin - 2-5 wrestlers, place 1-4.
- - Two Pools of 4 (3 matches each) to a semi final bracket - 6-8 wrestlers, place 1-4.
+ - Single pool round robin - 2-6 wrestlers, place 1-4.
+ - Two Pools of 4 (3 matches each) to a semi final bracket - 7-8 wrestlers, place 1-4.
- Two Pools of 5 (4 matches each) to a championship and 3rd/4th match - 8-10 wrestlers, place 1-4.
- Four pools of 3 (2 matches each) to a quarter final bracket - 9-12 wrestlers, place 1-8.
- Four pools of 4 (3 matches each) to a semi final bracket - 13-16 wrestlers, place 1-8.
diff --git a/test/models/tournament_test.rb b/test/models/tournament_test.rb
index 0390022..2a66672 100644
--- a/test/models/tournament_test.rb
+++ b/test/models/tournament_test.rb
@@ -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"
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8ecdd46..a44e3be 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -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