mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Fixed bug with pool to bracket advancement. This bug was conceived due to the removing of tests and logic when making pool and pool_placement database fields.
This commit is contained in:
37
test/integration/pool_to_bracket_advancement_test.rb
Normal file
37
test/integration/pool_to_bracket_advancement_test.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PoolToBracketAdvancementTest < ActionDispatch::IntegrationTest
|
||||
|
||||
def setup
|
||||
@tournament = create_pool_tournament_single_weight(10)
|
||||
@weight = Weight.where("tournament_id = ? and max = 106", @tournament.id).first
|
||||
end
|
||||
|
||||
def end_all_pool_matches
|
||||
matches = Match.where("weight_id = ? and bracket_position = 'Pool'",@weight.id)
|
||||
matches.each do |match|
|
||||
if match.wrestler1.bracket_line < match.wrestler2.bracket_line
|
||||
match.winner_id = match.w1
|
||||
else
|
||||
match.winner_id = match.w2
|
||||
end
|
||||
match.finished = 1
|
||||
match.score = "2-1"
|
||||
match.save
|
||||
end
|
||||
end
|
||||
|
||||
test "Pool winners are wrestling for first and pool losers are wrestling for third in two pools to finals pool bracket" do
|
||||
end_all_pool_matches
|
||||
pool_winner_1 = Wrestler.where("weight_id = ? and pool = 1 and pool_placement = 1",@weight.id).first
|
||||
pool_runnerup_1 = Wrestler.where("weight_id = ? and pool = 1 and pool_placement = 2",@weight.id).first
|
||||
pool_winner_2 = Wrestler.where("weight_id = ? and pool = 2 and pool_placement = 1",@weight.id).first
|
||||
pool_runnerup_2 = Wrestler.where("weight_id = ? and pool = 2 and pool_placement = 2",@weight.id).first
|
||||
match_1_2 = Match.where("weight_id = ? and bracket_position = '1/2'", @weight.id).first
|
||||
match_3_4 = Match.where("weight_id = ? and bracket_position = '3/4'", @weight.id).first
|
||||
assert match_1_2.wrestler_in_match(pool_winner_1) == true
|
||||
assert match_1_2.wrestler_in_match(pool_winner_2) == true
|
||||
assert match_3_4.wrestler_in_match(pool_runnerup_1) == true
|
||||
assert match_3_4.wrestler_in_match(pool_runnerup_2) == true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user