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

Fixed issue with wrestlers having a pool number higher than possible when bracket types change after deleting wrestlers

This commit is contained in:
2019-01-19 16:18:20 +00:00
parent 30dc645375
commit 4eb75d45d3
3 changed files with 74 additions and 24 deletions

View File

@@ -0,0 +1,27 @@
require 'test_helper'
class EightPoolToFourPoolChangesTest < ActionDispatch::IntegrationTest
def setup
@tournament = Tournament.find(4)
end
test "All wrestlers get matches after a weight switches from 8 pool to 4 pool" do
GenerateTournamentMatches.new(@tournament).generate
assert @tournament.matches.count == 36
assert @tournament.weights.first.pools == 8
count = 1
@tournament.reload.weights.first.wrestlers.sort_by{|wrestler| wrestler.pool}.each do |wrestler|
if count <= 8
wrestler.destroy
count = count + 1
end
end
GenerateTournamentMatches.new(@tournament.reload).generate
assert @tournament.matches.count == 32
assert @tournament.weights.first.pools == 4
@tournament.reload.weights.first.wrestlers.each do |wrestler|
assert wrestler.pool <= 4
assert wrestler.all_matches.count > 0
end
end
end