1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Removed all of the @s from integration tests

This commit is contained in:
2015-11-16 16:25:28 +00:00
parent 2e1f70803b
commit 6436551f34
2 changed files with 147 additions and 152 deletions

View File

@@ -8,74 +8,74 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
end
def showNineManWeightThreePoolTwoMatches
@matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool" && m.poolNumber == 2}
@matches.each do |m|
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool" && m.poolNumber == 2}
matches.each do |m|
puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} Pool: #{m.poolNumber}"
end
end
def nineManBracketPoolOneOutrightWinner
@matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1002,"Guy8",@matches)
endMatch(1003,"Guy10",@matches)
endMatch(2002,"Guy2",@matches)
endMatch(2003,"Guy8",@matches)
endMatch(3003,"Guy2",@matches)
endMatch(4002,"Guy8",@matches)
endMatch(4003,"Guy2",@matches)
endMatch(5002,"Guy2",@matches)
endMatch(5003,"Guy5",@matches)
endMatch(3002,"Guy5",@matches)
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1002,"Guy8",matches)
endMatch(1003,"Guy10",matches)
endMatch(2002,"Guy2",matches)
endMatch(2003,"Guy8",matches)
endMatch(3003,"Guy2",matches)
endMatch(4002,"Guy8",matches)
endMatch(4003,"Guy2",matches)
endMatch(5002,"Guy2",matches)
endMatch(5003,"Guy5",matches)
endMatch(3002,"Guy5",matches)
end
def nineManBracketPoolTwoGuyNineHeadToHead
@matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1004,"Guy4",@matches)
endMatch(1005,"Guy3",@matches)
endMatch(2004,"Guy3",@matches)
endMatch(2005,"Guy9",@matches)
endMatch(3004,"Guy7",@matches)
endMatch(3005,"Guy9",@matches)
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1004,"Guy4",matches)
endMatch(1005,"Guy3",matches)
endMatch(2004,"Guy3",matches)
endMatch(2005,"Guy9",matches)
endMatch(3004,"Guy7",matches)
endMatch(3005,"Guy9",matches)
end
def nineManBracketPoolTwoGuyThreeHeadToHead
@matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1004,"Guy9",@matches)
endMatch(1005,"Guy3",@matches)
endMatch(2004,"Guy4",@matches)
endMatch(2005,"Guy9",@matches)
endMatch(3004,"Guy7",@matches)
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1004,"Guy9",matches)
endMatch(1005,"Guy3",matches)
endMatch(2004,"Guy4",matches)
endMatch(2005,"Guy9",matches)
endMatch(3004,"Guy7",matches)
#DEDUCTED POINTS SHOULD NOT MATTER FOR HEAD TO HEAD
@deduct = Teampointadjust.new
@deduct.wrestler_id = translateNameToId("Guy3")
@deduct.points = 1
@deduct.save
endMatch(3005,"Guy3",@matches)
deduct = Teampointadjust.new
deduct.wrestler_id = translateNameToId("Guy3")
deduct.points = 1
deduct.save
endMatch(3005,"Guy3",matches)
end
def nineManBracketPoolTwoGuyThreeDeductedPoints
@matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1004,"Guy9",@matches)
endMatch(1005,"Guy7",@matches)
endMatch(2004,"Guy3",@matches)
endMatch(2005,"Guy9",@matches)
endMatch(3004,"Guy7",@matches)
endMatch(3005,"Guy3",@matches)
@deduct = Teampointadjust.new
@deduct.wrestler_id = translateNameToId("Guy7")
@deduct.points = 1
@deduct.save
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1004,"Guy9",matches)
endMatch(1005,"Guy7",matches)
endMatch(2004,"Guy3",matches)
endMatch(2005,"Guy9",matches)
endMatch(3004,"Guy7",matches)
endMatch(3005,"Guy3",matches)
deduct = Teampointadjust.new
deduct.wrestler_id = translateNameToId("Guy7")
deduct.points = 1
deduct.save
end
def endMatch(bout,winner,matches)
@match = matches.select{|m| m.bout_number == bout}.first
@match.finished = 1
@match.winner_id = translateNameToId(winner)
@match.win_type = "Decision"
match = matches.select{|m| m.bout_number == bout}.first
match.finished = 1
match.winner_id = translateNameToId(winner)
match.win_type = "Decision"
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
@mat = @tournament.mats.first
@match.mat_id = @mat.id
@match.save
mat = @tournament.mats.first
match.mat_id = mat.id
match.save
end
def translateNameToId(wrestler)
Wrestler.where("name = ?", wrestler).first.id
@@ -83,54 +83,49 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
test "nine man outright finals advance" do
nineManBracketPoolOneOutrightWinner
@wrestler = Wrestler.where("name = ?", "Guy2").first
assert_equal 6000, @wrestler.boutByRound(6)
wrestler = Wrestler.where("name = ?", "Guy2").first
assert_equal 6000, wrestler.boutByRound(6)
end
test "nine man outright conso finals advance" do
nineManBracketPoolOneOutrightWinner
@wrestler = Wrestler.where("name = ?", "Guy8").first
assert_equal 6001, @wrestler.boutByRound(6)
wrestler = Wrestler.where("name = ?", "Guy8").first
assert_equal 6001, wrestler.boutByRound(6)
end
test "nine man pool 2 man to man tie breaker finalist guy 9" do
@wrestler = Wrestler.where("name = ?", "Guy9").first
wrestler = Wrestler.where("name = ?", "Guy9").first
nineManBracketPoolTwoGuyNineHeadToHead
assert_equal 6000, @wrestler.boutByRound(6)
assert_equal 6000, wrestler.boutByRound(6)
end
test "nine man pool 2 man to man tie breaker finalist guy 3" do
@wrestler = Wrestler.where("name = ?", "Guy3").first
wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeHeadToHead
assert_equal 6000, @wrestler.boutByRound(6)
assert_equal 6000, wrestler.boutByRound(6)
end
test "nine man conso finals man to man tie breaker guy 3" do
nineManBracketPoolTwoGuyNineHeadToHead
@wrestler = Wrestler.where("name = ?", "Guy3").first
assert_equal 6001, @wrestler.boutByRound(6)
wrestler = Wrestler.where("name = ?", "Guy3").first
assert_equal 6001, wrestler.boutByRound(6)
end
test "nine man conso finals man to man tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeHeadToHead
@wrestler = Wrestler.where("name = ?", "Guy9").first
# @match = Match.where(bout_number: 6001).first
# puts "#{@match.w1_name} v #{@match.w2_name}"
assert_equal 6001, @wrestler.boutByRound(6)
wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6)
end
test "nine man pool 2 deductedPoints tie breaker finalist guy 3" do
@wrestler = Wrestler.where("name = ?", "Guy3").first
wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeDeductedPoints
assert_equal 6000, @wrestler.boutByRound(6)
assert_equal 6000, wrestler.boutByRound(6)
end
test "nine man conso finals deductedPoints tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeDeductedPoints
@wrestler = Wrestler.where("name = ?", "Guy9").first
# @match = Match.where(bout_number: 6001).first
# puts "#{@match.w1_name} v #{@match.w2_name}"
assert_equal 6001, @wrestler.boutByRound(6)
wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6)
end
end

View File

@@ -3,7 +3,7 @@ require 'test_helper'
class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
def setup
@tournament = Tournament.find(1)
@genMatchups = @tournament.generateMatchups
@tournament.generateMatchups
end
def createTournament(numberOfWrestlers)
@@ -98,7 +98,7 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
end
test "tests bout numbers correspond to round" do
matchup_to_test = @genMatchups.select{|m| m.bout_number == 4000}.first
matchup_to_test = @tournament.matches.select{|m| m.bout_number == 4000}.first
assert_equal 4, matchup_to_test.round
end
@@ -109,28 +109,28 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
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
six_matches = @tournament.matches.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
twentysix_matches = @tournament.matches.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
twentysix_matches = @tournament.matches.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
twentysix_matches = @tournament.matches.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
twentysix_matches = @tournament.matches.select{|m| m.weight_max == 132}
assert_equal 32, twentysix_matches.length
end
test "test if a wrestler can exceed five matches" do
@@ -141,112 +141,112 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
end
test "test loser names for 16 man bracket 3/4th place match" do
@matches = @tournament.matches.where(weight_id: 5)
@semi_bouts = @matches.where(bracket_position: 'Semis')
@third_fourth_match = @matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{@semi_bouts.first.bout_number}", @third_fourth_match.loser1_name
assert_equal "Loser of #{@semi_bouts.second.bout_number}", @third_fourth_match.loser2_name
matches = @tournament.matches.where(weight_id: 5)
semi_bouts = matches.where(bracket_position: 'Semis')
third_fourth_match = matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{semi_bouts.first.bout_number}", third_fourth_match.loser1_name
assert_equal "Loser of #{semi_bouts.second.bout_number}", third_fourth_match.loser2_name
end
test "test loser names for 16 man bracket 7/8th place match" do
@matches = @tournament.matches.where(weight_id: 5)
@conso_semi_bouts = @matches.where(bracket_position: 'Conso Semis')
@seven_eight_match = @matches.where(bracket_position: '7/8').first
assert_equal "Loser of #{@conso_semi_bouts.first.bout_number}", @seven_eight_match.loser1_name
assert_equal "Loser of #{@conso_semi_bouts.second.bout_number}", @seven_eight_match.loser2_name
matches = @tournament.matches.where(weight_id: 5)
conso_semi_bouts = matches.where(bracket_position: 'Conso Semis')
seven_eight_match = matches.where(bracket_position: '7/8').first
assert_equal "Loser of #{conso_semi_bouts.first.bout_number}", seven_eight_match.loser1_name
assert_equal "Loser of #{conso_semi_bouts.second.bout_number}", seven_eight_match.loser2_name
end
test "test loser names for 16 man bracket semis" do
@matches = @tournament.matches.where(weight_id: 5)
@semi_bouts = @matches.where(bracket_position: 'Semis')
assert_equal "Winner Pool 1", @semi_bouts.first.loser1_name
assert_equal "Winner Pool 4", @semi_bouts.first.loser2_name
assert_equal "Winner Pool 2", @semi_bouts.second.loser1_name
assert_equal "Winner Pool 3", @semi_bouts.second.loser2_name
matches = @tournament.matches.where(weight_id: 5)
semi_bouts = matches.where(bracket_position: 'Semis')
assert_equal "Winner Pool 1", semi_bouts.first.loser1_name
assert_equal "Winner Pool 4", semi_bouts.first.loser2_name
assert_equal "Winner Pool 2", semi_bouts.second.loser1_name
assert_equal "Winner Pool 3", semi_bouts.second.loser2_name
end
test "test loser names for 16 man bracket conso semis" do
@matches = @tournament.matches.where(weight_id: 5)
@conso_semi_bouts = @matches.where(bracket_position: 'Conso Semis')
assert_equal "Runner Up Pool 1", @conso_semi_bouts.first.loser1_name
assert_equal "Runner Up Pool 4", @conso_semi_bouts.first.loser2_name
assert_equal "Runner Up Pool 2", @conso_semi_bouts.second.loser1_name
assert_equal "Runner Up Pool 3", @conso_semi_bouts.second.loser2_name
matches = @tournament.matches.where(weight_id: 5)
conso_semi_bouts = matches.where(bracket_position: 'Conso Semis')
assert_equal "Runner Up Pool 1", conso_semi_bouts.first.loser1_name
assert_equal "Runner Up Pool 4", conso_semi_bouts.first.loser2_name
assert_equal "Runner Up Pool 2", conso_semi_bouts.second.loser1_name
assert_equal "Runner Up Pool 3", conso_semi_bouts.second.loser2_name
end
test "test loser names for 11 man bracket 3/4th place match" do
@matches = @tournament.matches.where(weight_id: 4)
@semi_bouts = @matches.where(bracket_position: 'Semis')
@third_fourth_match = @matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{@semi_bouts.first.bout_number}", @third_fourth_match.loser1_name
assert_equal "Loser of #{@semi_bouts.second.bout_number}", @third_fourth_match.loser2_name
matches = @tournament.matches.where(weight_id: 4)
semi_bouts = matches.where(bracket_position: 'Semis')
third_fourth_match = matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{semi_bouts.first.bout_number}", third_fourth_match.loser1_name
assert_equal "Loser of #{semi_bouts.second.bout_number}", third_fourth_match.loser2_name
end
test "test loser names for 11 man bracket 7/8th place match" do
@matches = @tournament.matches.where(weight_id: 4)
@conso_semi_bouts = @matches.where(bracket_position: 'Conso Semis')
@seven_eight_match = @matches.where(bracket_position: '7/8').first
assert_equal "Loser of #{@conso_semi_bouts.first.bout_number}", @seven_eight_match.loser1_name
assert_equal "Loser of #{@conso_semi_bouts.second.bout_number}", @seven_eight_match.loser2_name
matches = @tournament.matches.where(weight_id: 4)
conso_semi_bouts = matches.where(bracket_position: 'Conso Semis')
seven_eight_match = matches.where(bracket_position: '7/8').first
assert_equal "Loser of #{conso_semi_bouts.first.bout_number}", seven_eight_match.loser1_name
assert_equal "Loser of #{conso_semi_bouts.second.bout_number}", seven_eight_match.loser2_name
end
test "test loser names for 11 man bracket quarters" do
@matches = @tournament.matches.where(weight_id: 4)
@quarters = @matches.where(bracket_position: 'Quarter')
assert_equal "Winner Pool 1", @quarters.first.loser1_name
assert_equal "Runner Up Pool 2", @quarters.first.loser2_name
assert_equal "Winner Pool 4", @quarters.second.loser1_name
assert_equal "Runner Up Pool 3", @quarters.second.loser2_name
assert_equal "Winner Pool 2", @quarters.third.loser1_name
assert_equal "Runner Up Pool 1", @quarters.third.loser2_name
assert_equal "Winner Pool 3", @quarters.fourth.loser1_name
assert_equal "Runner Up Pool 4", @quarters.fourth.loser2_name
matches = @tournament.matches.where(weight_id: 4)
quarters = matches.where(bracket_position: 'Quarter')
assert_equal "Winner Pool 1", quarters.first.loser1_name
assert_equal "Runner Up Pool 2", quarters.first.loser2_name
assert_equal "Winner Pool 4", quarters.second.loser1_name
assert_equal "Runner Up Pool 3", quarters.second.loser2_name
assert_equal "Winner Pool 2", quarters.third.loser1_name
assert_equal "Runner Up Pool 1", quarters.third.loser2_name
assert_equal "Winner Pool 3", quarters.fourth.loser1_name
assert_equal "Runner Up Pool 4", quarters.fourth.loser2_name
end
test "test loser names for 11 man bracket conso semis" do
@matches = @tournament.matches.where(weight_id: 4)
@quarters = @matches.where(bracket_position: 'Quarter')
@conso_semi_bouts = @matches.where(bracket_position: 'Conso Semis')
assert_equal "Loser of #{@quarters.first.bout_number}", @conso_semi_bouts.first.loser1_name
assert_equal "Loser of #{@quarters.second.bout_number}", @conso_semi_bouts.first.loser2_name
assert_equal "Loser of #{@quarters.third.bout_number}", @conso_semi_bouts.second.loser1_name
assert_equal "Loser of #{@quarters.fourth.bout_number}", @conso_semi_bouts.second.loser2_name
matches = @tournament.matches.where(weight_id: 4)
quarters = matches.where(bracket_position: 'Quarter')
conso_semi_bouts = matches.where(bracket_position: 'Conso Semis')
assert_equal "Loser of #{quarters.first.bout_number}", conso_semi_bouts.first.loser1_name
assert_equal "Loser of #{quarters.second.bout_number}", conso_semi_bouts.first.loser2_name
assert_equal "Loser of #{quarters.third.bout_number}", conso_semi_bouts.second.loser1_name
assert_equal "Loser of #{quarters.fourth.bout_number}", conso_semi_bouts.second.loser2_name
end
test "test loser names for 9 man bracket 3/4th place match" do
@matches = @tournament.matches.where(weight_id: 3)
@third_fourth_match = @matches.where(bracket_position: '3/4').first
assert_equal "Runner Up Pool 1", @third_fourth_match.loser1_name
assert_equal "Runner Up Pool 2", @third_fourth_match.loser2_name
matches = @tournament.matches.where(weight_id: 3)
third_fourth_match = matches.where(bracket_position: '3/4').first
assert_equal "Runner Up Pool 1", third_fourth_match.loser1_name
assert_equal "Runner Up Pool 2", third_fourth_match.loser2_name
end
test "test loser names for 9 man bracket 1/2 place match" do
@matches = @tournament.matches.where(weight_id: 3)
@final_match = @matches.where(bracket_position: '1/2').first
assert_equal "Winner Pool 1", @final_match.loser1_name
assert_equal "Winner Pool 2", @final_match.loser2_name
matches = @tournament.matches.where(weight_id: 3)
final_match = matches.where(bracket_position: '1/2').first
assert_equal "Winner Pool 1", final_match.loser1_name
assert_equal "Winner Pool 2", final_match.loser2_name
end
test "test loser names for 7 man bracket 3/4th place match" do
@matches = @tournament.matches.where(weight_id: 2)
@semi_bouts = @matches.where(bracket_position: 'Semis')
@third_fourth_match = @matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{@semi_bouts.first.bout_number}", @third_fourth_match.loser1_name
assert_equal "Loser of #{@semi_bouts.second.bout_number}", @third_fourth_match.loser2_name
matches = @tournament.matches.where(weight_id: 2)
semi_bouts = matches.where(bracket_position: 'Semis')
third_fourth_match = matches.where(bracket_position: '3/4').first
assert_equal "Loser of #{semi_bouts.first.bout_number}", third_fourth_match.loser1_name
assert_equal "Loser of #{semi_bouts.second.bout_number}", third_fourth_match.loser2_name
end
test "test loser names for 7 man bracket semis" do
@matches = @tournament.matches.where(weight_id: 2)
@semi_bouts = @matches.where(bracket_position: 'Semis')
assert_equal "Winner Pool 1", @semi_bouts.first.loser1_name
assert_equal "Runner Up Pool 2", @semi_bouts.first.loser2_name
assert_equal "Winner Pool 2", @semi_bouts.second.loser1_name
assert_equal "Runner Up Pool 1", @semi_bouts.second.loser2_name
matches = @tournament.matches.where(weight_id: 2)
semi_bouts = matches.where(bracket_position: 'Semis')
assert_equal "Winner Pool 1", semi_bouts.first.loser1_name
assert_equal "Runner Up Pool 2", semi_bouts.first.loser2_name
assert_equal "Winner Pool 2", semi_bouts.second.loser1_name
assert_equal "Runner Up Pool 1", semi_bouts.second.loser2_name
end
test 'test mat assignment after match generation' do
@matches = @tournament.matches.order(:bout_number)
assert_equal 'Mat1', @matches.first.mat.name
matches = @tournament.matches.order(:bout_number)
assert_equal 'Mat1', matches.first.mat.name
end
end