mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-10 07:48:29 +00:00
Created integration test for poolbracket matchups
This commit is contained in:
@@ -7,7 +7,7 @@ class Matchup
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_to_obj(h)
|
def convert_to_obj(h)
|
||||||
h.each do |k,v|
|
h.each do |k,v|
|
||||||
self.class.send(:attr_accessor, k)
|
self.class.send(:attr_accessor, k)
|
||||||
instance_variable_set("@#{k}", v)
|
instance_variable_set("@#{k}", v)
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ class Tournament < ActiveRecord::Base
|
|||||||
def generateMatchups
|
def generateMatchups
|
||||||
@matches = []
|
@matches = []
|
||||||
self.weights.map.sort_by{|x|[x.max]}.each do |weight|
|
self.weights.map.sort_by{|x|[x.max]}.each do |weight|
|
||||||
@upcomingMatches = weight.generateMatchups(@matches)
|
@matches = weight.generateMatchups(@matches)
|
||||||
end
|
end
|
||||||
@upcomingMatches = assignBouts(@upcomingMatches)
|
@matches = assignBouts(@matches)
|
||||||
return @upcomingMatches
|
return @matches
|
||||||
end
|
end
|
||||||
|
|
||||||
def assignBouts(matches)
|
def assignBouts(matches)
|
||||||
|
|||||||
@@ -92,9 +92,9 @@ class Weight < ActiveRecord::Base
|
|||||||
return "twoPoolsToSemi"
|
return "twoPoolsToSemi"
|
||||||
elsif self.wrestlers.size > 8 && self.wrestlers.size <= 10
|
elsif self.wrestlers.size > 8 && self.wrestlers.size <= 10
|
||||||
return "twoPoolsToFinal"
|
return "twoPoolsToFinal"
|
||||||
elsif self.wrestlers.size == 11
|
elsif self.wrestlers.size == 11 || self.wrestlers.size == 12
|
||||||
return "fourPoolsToQuarter"
|
return "fourPoolsToQuarter"
|
||||||
elsif self.wrestlers.size > 11 && self.wrestlers.size <= 16
|
elsif self.wrestlers.size > 12 && self.wrestlers.size <= 16
|
||||||
return "fourPoolsToSemi"
|
return "fourPoolsToSemi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
36
test/fixtures/wrestlers.yml
vendored
36
test/fixtures/wrestlers.yml
vendored
@@ -394,4 +394,40 @@ fourtyfour:
|
|||||||
original_seed: 12
|
original_seed: 12
|
||||||
season_loss: 2
|
season_loss: 2
|
||||||
season_win: 50
|
season_win: 50
|
||||||
|
criteria:
|
||||||
|
|
||||||
|
fourtyfive:
|
||||||
|
name: Guy34
|
||||||
|
school_id: 1
|
||||||
|
weight_id: 5
|
||||||
|
original_seed: 13
|
||||||
|
season_loss: 2
|
||||||
|
season_win: 50
|
||||||
|
criteria:
|
||||||
|
|
||||||
|
fourtysix:
|
||||||
|
name: Guy35
|
||||||
|
school_id: 1
|
||||||
|
weight_id: 5
|
||||||
|
original_seed: 14
|
||||||
|
season_loss: 2
|
||||||
|
season_win: 50
|
||||||
|
criteria:
|
||||||
|
|
||||||
|
fourtyseven:
|
||||||
|
name: Guy36
|
||||||
|
school_id: 1
|
||||||
|
weight_id: 5
|
||||||
|
original_seed: 15
|
||||||
|
season_loss: 2
|
||||||
|
season_win: 50
|
||||||
|
criteria:
|
||||||
|
|
||||||
|
fourtyeight:
|
||||||
|
name: Guy37
|
||||||
|
school_id: 1
|
||||||
|
weight_id: 5
|
||||||
|
original_seed: 16
|
||||||
|
season_loss: 2
|
||||||
|
season_win: 50
|
||||||
criteria:
|
criteria:
|
||||||
52
test/integration/poolbracket_matchups_test.rb
Normal file
52
test/integration/poolbracket_matchups_test.rb
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||||
|
def setup
|
||||||
|
@tournament = Tournament.find(1)
|
||||||
|
@genMatchups = @tournament.generateMatchups
|
||||||
|
end
|
||||||
|
|
||||||
|
test "the truth" do
|
||||||
|
assert true
|
||||||
|
end
|
||||||
|
|
||||||
|
test "found tournament" do
|
||||||
|
refute_nil @tournament
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests boutNumber matches round" do
|
||||||
|
@matchup_to_test = @genMatchups.select{|m| m.boutNumber == 4000}.first
|
||||||
|
assert_equal 4, @matchup_to_test.round
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests boutNumbers are generated with smallest weight first regardless of id" do
|
||||||
|
@weight = @tournament.weights.map.sort_by{|x|[x.max]}.first
|
||||||
|
@matchup = @genMatchups.select{|m| m.boutNumber == 1000}.first
|
||||||
|
assert_equal @weight.max, @matchup.weight_max
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests number of matches in 5 man one pool" do
|
||||||
|
@six_matches = @genMatchups.select{|m| m.weight_max == 106}
|
||||||
|
assert_equal 10, @six_matches.length
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests number of matches in 11 man pool bracket" do
|
||||||
|
@twentysix_matches = @genMatchups.select{|m| m.weight_max == 126}
|
||||||
|
assert_equal 22, @twentysix_matches.length
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests number of matches in 9 man pool bracket" do
|
||||||
|
@twentysix_matches = @genMatchups.select{|m| m.weight_max == 113}
|
||||||
|
assert_equal 18, @twentysix_matches.length
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests number of matches in 7 man pool bracket" do
|
||||||
|
@twentysix_matches = @genMatchups.select{|m| m.weight_max == 120}
|
||||||
|
assert_equal 13, @twentysix_matches.length
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tests number of matches in 16 man pool bracket" do
|
||||||
|
@twentysix_matches = @genMatchups.select{|m| m.weight_max == 132}
|
||||||
|
assert_equal 32, @twentysix_matches.length
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user