From 119a97ebb73b831d4039b4f44e6e1f2657a6157c Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 3 Dec 2015 20:28:06 +0000 Subject: [PATCH] Fixing tests, still not working --- test/controllers/matches_controller_test.rb | 2 +- .../.poolbracket_matchups_test.rb.swp | Bin 20480 -> 0 bytes test/integration/pool_advancement_test.rb | 116 +++++++++++++++--- 3 files changed, 98 insertions(+), 20 deletions(-) delete mode 100644 test/integration/.poolbracket_matchups_test.rb.swp diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb index 8ee41d7..6d7cd71 100644 --- a/test/controllers/matches_controller_test.rb +++ b/test/controllers/matches_controller_test.rb @@ -68,7 +68,7 @@ class MatchesControllerTest < ActionController::TestCase test "logged in tournament owner should post update match" do sign_in_owner post_update - assert_redirected_to tournament_path(@match.tournament_id) + assert_redirected_to mat_path(1) end diff --git a/test/integration/.poolbracket_matchups_test.rb.swp b/test/integration/.poolbracket_matchups_test.rb.swp deleted file mode 100644 index d5cf75547ee2773eeebb83547fe0d1368d77c30b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeI4Ym6IL700K9LMcgG5~3DT(5(YquezPJcQ-FXqD?}YY)P85yPM_NVb;F3huAaj z%s5^*2`!?cMU@b(k}r*-fCLo?lz!k#1FfjaGf0&hA|fQ<3m=eZkOCDEMF_$F-nrws z^RRbZkrbh^`itYauXE2i_uR+abg^)7W*^z4PAT}@q9{*&`1t%c-+!a>(_0m#LJ!l1 z)uJ{_8}LECyE{gc+T{V6ko1LKh2yByu}r-&-m$6UHVm`2z113b@%M4VbZO1jUBfcR zTb9*WwDs~K>S|5hE!W#EM`O8EdvS1ES!$+%Oaqbz+HUpk&8w8jiDH30U7x#ytXVxT zWyt=TX&}=;rh!ZYnFcZqWE#jckZB;(!2i1j+|~-^5p?oxqN9(C@9QGpZx_F3#P<`C z^cCXwnD{;)Nf$q}uS^4(1~Ls~8pt$|X&}=;rh!ZYnFcZqWE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_advancement_test.rb b/test/integration/pool_advancement_test.rb index 90d9dee..8583bf7 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -5,17 +5,19 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest def setup @tournament = Tournament.find(1) @tournament.generateMatchups + @matches = @tournament.matches end - def showNineManWeightThreePoolTwoMatches - matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool" && m.poolNumber == 2} + def showMatches + matches = Match.where(weight_id: 4) + # matches = @matches.select{|m| m.weight_id == 4} 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 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(1003,"Guy10",matches) endMatch(2002,"Guy2",matches) @@ -29,7 +31,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end 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(1005,"Guy3",matches) endMatch(2004,"Guy3",matches) @@ -39,7 +41,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end 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(1005,"Guy3",matches) endMatch(2004,"Guy4",matches) @@ -54,7 +56,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end 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(1005,"Guy7",matches) endMatch(2004,"Guy3",matches) @@ -68,7 +70,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end 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(1005,"Guy7",matches) endMatchWithMajor(2004,"Guy3",matches) @@ -78,7 +80,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end 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) endMatch(1005,"Guy7",matches) endMatchWithPin(2004,"Guy3",matches) @@ -88,7 +90,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end 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) endMatchWithMajor(1003,"Guy10",matches) endMatchWithMajor(2002,"Guy2",matches) @@ -101,6 +103,43 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest endMatch(5003,"Guy5",matches) 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) match = matches.select{|m| m.bout_number == bout}.first match.finished = 1 @@ -267,7 +306,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "advancement points winner 1/2" do nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolTwoGuyThreeHeadToHead - endMatch(6000,"Guy2",@tournament.matches) + endMatch(6000,"Guy2",@matches) wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 16, wrestler1.placementPoints end @@ -275,13 +314,13 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "advancement points winner 3/4" do nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolTwoGuyThreeHeadToHead - endMatch(6001,"Guy8",@tournament.matches) + endMatch(6001,"Guy8",@matches) wrestler1 = Wrestler.where("name = ?", "Guy8").first assert_equal 10, wrestler1.placementPoints end test "advancement points winner 5/6" do - + end test "advancement points winner 7/8" do @@ -289,35 +328,74 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end test "bonus points major" do - endMatchWithMajor(2002,"Guy2",@tournament.matches) + endMatchWithMajor(2002,"Guy2",@matches) wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 2, wrestler1.teamPointsEarned end test "bonus points pin" do - endMatchWithPin(2002,"Guy2",@tournament.matches) + endMatchWithPin(2002,"Guy2",@matches) wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 3, wrestler1.teamPointsEarned end test "bonus points tech fall" do - endMatchWithTech(2002,"Guy2",@tournament.matches) + endMatchWithTech(2002,"Guy2",@matches) wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 2.5, wrestler1.teamPointsEarned end test "pool team points win" do - endMatch(2002,"Guy2",@tournament.matches) + endMatch(2002,"Guy2",@matches) wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 1, wrestler1.teamPointsEarned end test "advancement points fourPoolsToQuarter Quarter" do - + elevenManBracketToQuarter + wrestler1 = Wrestler.where("name = ?", "Guy11").first + assert_equal 3, wrestler1.placementPoints end 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 test "advancement points twoPoolsToSemi Semis" do