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:
27
test/integration/eight_pool_to_four_pool_changes_test.rb
Normal file
27
test/integration/eight_pool_to_four_pool_changes_test.rb
Normal 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
|
||||
Reference in New Issue
Block a user