mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-13 16:40:48 +00:00
Fixing tests, still not working
This commit is contained in:
@@ -68,7 +68,7 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
test "logged in tournament owner should post update match" do
|
test "logged in tournament owner should post update match" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_update
|
post_update
|
||||||
assert_redirected_to tournament_path(@match.tournament_id)
|
assert_redirected_to mat_path(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -5,17 +5,19 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
def setup
|
def setup
|
||||||
@tournament = Tournament.find(1)
|
@tournament = Tournament.find(1)
|
||||||
@tournament.generateMatchups
|
@tournament.generateMatchups
|
||||||
|
@matches = @tournament.matches
|
||||||
end
|
end
|
||||||
|
|
||||||
def showNineManWeightThreePoolTwoMatches
|
def showMatches
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool" && m.poolNumber == 2}
|
matches = Match.where(weight_id: 4)
|
||||||
|
# matches = @matches.select{|m| m.weight_id == 4}
|
||||||
matches.each do |m|
|
matches.each do |m|
|
||||||
puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} Pool: #{m.poolNumber}"
|
puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolOneOutrightWinnerGuyTwo
|
def nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatch(1002,"Guy8",matches)
|
endMatch(1002,"Guy8",matches)
|
||||||
endMatch(1003,"Guy10",matches)
|
endMatch(1003,"Guy10",matches)
|
||||||
endMatch(2002,"Guy2",matches)
|
endMatch(2002,"Guy2",matches)
|
||||||
@@ -29,7 +31,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyNineHeadToHead
|
def nineManBracketPoolTwoGuyNineHeadToHead
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatch(1004,"Guy4",matches)
|
endMatch(1004,"Guy4",matches)
|
||||||
endMatch(1005,"Guy3",matches)
|
endMatch(1005,"Guy3",matches)
|
||||||
endMatch(2004,"Guy3",matches)
|
endMatch(2004,"Guy3",matches)
|
||||||
@@ -39,7 +41,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeHeadToHead
|
def nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatch(1004,"Guy9",matches)
|
endMatch(1004,"Guy9",matches)
|
||||||
endMatch(1005,"Guy3",matches)
|
endMatch(1005,"Guy3",matches)
|
||||||
endMatch(2004,"Guy4",matches)
|
endMatch(2004,"Guy4",matches)
|
||||||
@@ -54,7 +56,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeDeductedPoints
|
def nineManBracketPoolTwoGuyThreeDeductedPoints
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatch(1004,"Guy9",matches)
|
endMatch(1004,"Guy9",matches)
|
||||||
endMatch(1005,"Guy7",matches)
|
endMatch(1005,"Guy7",matches)
|
||||||
endMatch(2004,"Guy3",matches)
|
endMatch(2004,"Guy3",matches)
|
||||||
@@ -68,7 +70,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeTeamPoints
|
def nineManBracketPoolTwoGuyThreeTeamPoints
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatch(1004,"Guy9",matches)
|
endMatch(1004,"Guy9",matches)
|
||||||
endMatch(1005,"Guy7",matches)
|
endMatch(1005,"Guy7",matches)
|
||||||
endMatchWithMajor(2004,"Guy3",matches)
|
endMatchWithMajor(2004,"Guy3",matches)
|
||||||
@@ -78,7 +80,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeMostPins
|
def nineManBracketPoolTwoGuyThreeMostPins
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatchWithMajor(1004,"Guy9",matches)
|
endMatchWithMajor(1004,"Guy9",matches)
|
||||||
endMatch(1005,"Guy7",matches)
|
endMatch(1005,"Guy7",matches)
|
||||||
endMatchWithPin(2004,"Guy3",matches)
|
endMatchWithPin(2004,"Guy3",matches)
|
||||||
@@ -88,7 +90,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nineManBracketPoolOneGuyEightMostTechs
|
def nineManBracketPoolOneGuyEightMostTechs
|
||||||
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
endMatchWithTech(1002,"Guy8",matches)
|
endMatchWithTech(1002,"Guy8",matches)
|
||||||
endMatchWithMajor(1003,"Guy10",matches)
|
endMatchWithMajor(1003,"Guy10",matches)
|
||||||
endMatchWithMajor(2002,"Guy2",matches)
|
endMatchWithMajor(2002,"Guy2",matches)
|
||||||
@@ -101,6 +103,43 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
endMatch(5003,"Guy5",matches)
|
endMatch(5003,"Guy5",matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def elevenManBracketToQuarter
|
||||||
|
matches = @matches
|
||||||
|
endMatch(1009,"Guy11",matches)
|
||||||
|
endMatch(2009,"Guy11",matches)
|
||||||
|
endMatch(3009,"Guy17",matches)
|
||||||
|
endMatch(1010,"Guy12",matches)
|
||||||
|
endMatch(2010,"Guy12",matches)
|
||||||
|
endMatch(3010,"Guy16",matches)
|
||||||
|
endMatch(1011,"Guy15",matches)
|
||||||
|
endMatch(2011,"Guy15",matches)
|
||||||
|
endMatch(3011,"Guy19",matches)
|
||||||
|
endMatch(1012,"Guy14",matches)
|
||||||
|
end
|
||||||
|
def elevenManBracketToSemis
|
||||||
|
matches = @matches
|
||||||
|
endMatch(4006,"Guy11",matches)
|
||||||
|
endMatch(4007,"Guy14",matches)
|
||||||
|
endMatch(4008,"Guy12",matches)
|
||||||
|
endMatch(4009,"Guy15",matches)
|
||||||
|
end
|
||||||
|
|
||||||
|
def elevenManBracketToFinals
|
||||||
|
matches = @matches
|
||||||
|
endMatch(5006,"Guy11",matches)
|
||||||
|
endMatch(5007,"Guy12",matches)
|
||||||
|
endMatch(5008,"Guy16",matches)
|
||||||
|
endMatch(5009,"Guy17",matches)
|
||||||
|
end
|
||||||
|
|
||||||
|
def elevenManBracketFinished
|
||||||
|
matches = @matches
|
||||||
|
endMatch(6002,"Guy11",matches)
|
||||||
|
endMatch(6003,"Guy14",matches)
|
||||||
|
endMatch(6004,"Guy16",matches)
|
||||||
|
endMatch(6005,"Guy19",matches)
|
||||||
|
end
|
||||||
|
|
||||||
def endMatch(bout,winner,matches)
|
def endMatch(bout,winner,matches)
|
||||||
match = matches.select{|m| m.bout_number == bout}.first
|
match = matches.select{|m| m.bout_number == bout}.first
|
||||||
match.finished = 1
|
match.finished = 1
|
||||||
@@ -267,7 +306,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
test "advancement points winner 1/2" do
|
test "advancement points winner 1/2" do
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
endMatch(6000,"Guy2",@tournament.matches)
|
endMatch(6000,"Guy2",@matches)
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
assert_equal 16, wrestler1.placementPoints
|
assert_equal 16, wrestler1.placementPoints
|
||||||
end
|
end
|
||||||
@@ -275,13 +314,13 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
test "advancement points winner 3/4" do
|
test "advancement points winner 3/4" do
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
endMatch(6001,"Guy8",@tournament.matches)
|
endMatch(6001,"Guy8",@matches)
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
||||||
assert_equal 10, wrestler1.placementPoints
|
assert_equal 10, wrestler1.placementPoints
|
||||||
end
|
end
|
||||||
|
|
||||||
test "advancement points winner 5/6" do
|
test "advancement points winner 5/6" do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "advancement points winner 7/8" do
|
test "advancement points winner 7/8" do
|
||||||
@@ -289,35 +328,74 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "bonus points major" do
|
test "bonus points major" do
|
||||||
endMatchWithMajor(2002,"Guy2",@tournament.matches)
|
endMatchWithMajor(2002,"Guy2",@matches)
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
assert_equal 2, wrestler1.teamPointsEarned
|
assert_equal 2, wrestler1.teamPointsEarned
|
||||||
end
|
end
|
||||||
|
|
||||||
test "bonus points pin" do
|
test "bonus points pin" do
|
||||||
endMatchWithPin(2002,"Guy2",@tournament.matches)
|
endMatchWithPin(2002,"Guy2",@matches)
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
assert_equal 3, wrestler1.teamPointsEarned
|
assert_equal 3, wrestler1.teamPointsEarned
|
||||||
end
|
end
|
||||||
|
|
||||||
test "bonus points tech fall" do
|
test "bonus points tech fall" do
|
||||||
endMatchWithTech(2002,"Guy2",@tournament.matches)
|
endMatchWithTech(2002,"Guy2",@matches)
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
assert_equal 2.5, wrestler1.teamPointsEarned
|
assert_equal 2.5, wrestler1.teamPointsEarned
|
||||||
end
|
end
|
||||||
|
|
||||||
test "pool team points win" do
|
test "pool team points win" do
|
||||||
endMatch(2002,"Guy2",@tournament.matches)
|
endMatch(2002,"Guy2",@matches)
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
assert_equal 1, wrestler1.teamPointsEarned
|
assert_equal 1, wrestler1.teamPointsEarned
|
||||||
end
|
end
|
||||||
|
|
||||||
test "advancement points fourPoolsToQuarter Quarter" do
|
test "advancement points fourPoolsToQuarter Quarter" do
|
||||||
|
elevenManBracketToQuarter
|
||||||
|
wrestler1 = Wrestler.where("name = ?", "Guy11").first
|
||||||
|
assert_equal 3, wrestler1.placementPoints
|
||||||
end
|
end
|
||||||
|
|
||||||
test "advancement points fourPoolsToQuarter Semis" do
|
test "advancement points fourPoolsToQuarter Semis" do
|
||||||
|
# elevenManBracketToQuarter
|
||||||
|
# elevenManBracketToSemis
|
||||||
|
# showMatches
|
||||||
|
|
||||||
|
matches = @matches
|
||||||
|
endMatch(1009,"Guy11",matches)
|
||||||
|
endMatch(2009,"Guy11",matches)
|
||||||
|
endMatch(3009,"Guy17",matches)
|
||||||
|
endMatch(1010,"Guy12",matches)
|
||||||
|
endMatch(2010,"Guy12",matches)
|
||||||
|
endMatch(3010,"Guy16",matches)
|
||||||
|
endMatch(1011,"Guy15",matches)
|
||||||
|
endMatch(2011,"Guy15",matches)
|
||||||
|
endMatch(3011,"Guy19",matches)
|
||||||
|
endMatch(1012,"Guy14",matches)
|
||||||
|
|
||||||
|
endMatch(4006,"Guy11",matches)
|
||||||
|
endMatch(4007,"Guy14",matches)
|
||||||
|
endMatch(4008,"Guy12",matches)
|
||||||
|
endMatch(4009,"Guy15",matches)
|
||||||
|
|
||||||
|
# showMatches
|
||||||
|
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy11").first
|
||||||
|
match = Match.where(bout_number: 4006).first
|
||||||
|
puts match.inspect
|
||||||
|
# puts Wrestler.find(match.winner_id).name
|
||||||
|
# match = Match.where(bout_number: 5006).first
|
||||||
|
# puts match.inspect
|
||||||
|
puts wrestler.weight.allPoolMatchesFinished(wrestler.generatePoolNumber)
|
||||||
|
puts wrestler.finishedBracketMatches.size
|
||||||
|
puts wrestler.lastMatch.bout_number
|
||||||
|
puts wrestler.winnerOfLastMatch?
|
||||||
|
puts wrestler.nextMatchPositionNumber.ceil
|
||||||
|
puts wrestler.nextMatchPositionNumber
|
||||||
|
match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Semis",wrestler.nextMatchPositionNumber,wrestler.weight_id).first
|
||||||
|
puts match.bout_number
|
||||||
|
assert_equal 9, wrestler.placementPoints
|
||||||
end
|
end
|
||||||
|
|
||||||
test "advancement points twoPoolsToSemi Semis" do
|
test "advancement points twoPoolsToSemi Semis" do
|
||||||
|
|||||||
Reference in New Issue
Block a user