mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Simplify construction a bit on some methods
This commit is contained in:
@@ -5,9 +5,8 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
@tournament = Tournament.find(1)
|
||||
@genMatchups = @tournament.upcomingMatches
|
||||
end
|
||||
|
||||
|
||||
def createTournament(numberOfWrestlers)
|
||||
@count = 1
|
||||
@id = 6000 + numberOfWrestlers
|
||||
@tournament3 = Tournament.new
|
||||
@tournament3.id = @id
|
||||
@@ -26,21 +25,22 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
@weight3.id = @id
|
||||
@weight3.tournament_id = @id
|
||||
@weight3.save
|
||||
until @count > numberOfWrestlers do
|
||||
@wrestler2 = Wrestler.new
|
||||
@wrestler2.name = "Guy #{@count}"
|
||||
@wrestler2.school_id = @id
|
||||
@wrestler2.weight_id = @id
|
||||
@wrestler2.original_seed = @count
|
||||
@wrestler2.season_loss = 0
|
||||
@wrestler2.season_win = 0
|
||||
@wrestler2.criteria = nil
|
||||
numberOfWrestlers.times do |x|
|
||||
count = x + 1
|
||||
@wrestler2 = Wrestler.new(
|
||||
name: "Guy #{count}",
|
||||
school_id: @id,
|
||||
weight_id: @id,
|
||||
original_seed: count,
|
||||
season_loss: 0,
|
||||
season_win: 0,
|
||||
criteria: nil
|
||||
)
|
||||
@wrestler2.save
|
||||
@count = @count + 1
|
||||
end
|
||||
return @tournament3
|
||||
end
|
||||
|
||||
|
||||
def checkForByeInPool(tournament)
|
||||
tournament.upcomingMatches
|
||||
@matchups = tournament.matches
|
||||
@@ -60,53 +60,48 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
|
||||
test "found tournament" do
|
||||
refute_nil @tournament
|
||||
end
|
||||
|
||||
|
||||
test "tests bout_number matches round" do
|
||||
@matchup_to_test = @genMatchups.select{|m| m.bout_number == 4000}.first
|
||||
assert_equal 4, @matchup_to_test.round
|
||||
end
|
||||
|
||||
|
||||
test "tests bout_numbers 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.bout_number == 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
|
||||
|
||||
|
||||
|
||||
test "test if a wrestler can exceed five matches" do
|
||||
@count = 5
|
||||
until @count > 16 do
|
||||
@@ -115,6 +110,6 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
@count = @count + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#todo test crazy movements through each bracket?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user