mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Fixed double elim bracket views, fixed double elim match generation and loser name generation for 4 man bracket, fixed seed page submission and added tests, added tests for tournament generation errors and added a new error for assigning a seed higher than the number of wrestlers.
This commit is contained in:
@@ -55,6 +55,10 @@ class TournamentsControllerTest < ActionController::TestCase
|
||||
assert_redirected_to '/static_pages/not_allowed'
|
||||
end
|
||||
|
||||
def redirect_tournament_error
|
||||
assert_redirected_to "/tournaments/#{@tournament.id}/error"
|
||||
end
|
||||
|
||||
def destroy
|
||||
delete :destroy, params: { id: 1 }
|
||||
end
|
||||
@@ -664,4 +668,83 @@ class TournamentsControllerTest < ActionController::TestCase
|
||||
updated_tournament = Tournament.find(new_tournament.id)
|
||||
assert_equal users(:one).id, updated_tournament.user_id, "The user_id should not change when the tournament is edited by a non-owner"
|
||||
end
|
||||
|
||||
test "tournament generation error when a wrestler has an original seed higher than the amount of wrestlers in the weight" do
|
||||
sign_in_owner
|
||||
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
wrestler = @tournament.weights.first.wrestlers.first
|
||||
wrestler.original_seed = 15
|
||||
wrestler.save
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
|
||||
test "tournament generation error when a double elimination tournament has too many wrestlers" do
|
||||
sign_in_owner
|
||||
create_double_elim_tournament_single_weight(16, "Regular Double Elimination 1-8")
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
create_wrestlers_for_weight_for_double_elim(@tournament.weights.first, @tournament.schools.first, 1, 20)
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
|
||||
test "tournament generation error when a double elimination tournament has too few wrestlers" do
|
||||
sign_in_owner
|
||||
create_double_elim_tournament_single_weight(4, "Regular Double Elimination 1-8")
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
@tournament.weights.first.wrestlers.first.destroy
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
|
||||
test "tournament generation error when a Modified 16 Man Double Elimination tournament has too many wrestlers" do
|
||||
sign_in_owner
|
||||
create_double_elim_tournament_single_weight(16, "Modified 16 Man Double Elimination 1-8")
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
create_wrestlers_for_weight_for_double_elim(@tournament.weights.first, @tournament.schools.first, 1, 20)
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
|
||||
test "tournament generation error when a Modified 16 Man Double Elimination tournament has too few wrestlers" do
|
||||
sign_in_owner
|
||||
create_double_elim_tournament_single_weight(12, "Modified 16 Man Double Elimination 1-8")
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
@tournament.weights.first.wrestlers.first.destroy
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
|
||||
test "tournament generation error when a pool to bracket tournament has too many wrestlers" do
|
||||
sign_in_owner
|
||||
create_pool_tournament_single_weight(24)
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
create_wrestlers_for_weight(@tournament.weights.first, @tournament.schools.first, 1, 20)
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
|
||||
test "tournament generation error when a pool to bracket tournament has too few wrestlers" do
|
||||
sign_in_owner
|
||||
create_pool_tournament_single_weight(2)
|
||||
@tournament.destroy_all_matches
|
||||
@tournament.user_id = 1
|
||||
@tournament.save
|
||||
@tournament.weights.first.wrestlers.first.destroy
|
||||
get :generate_matches, params: { id: @tournament.id }
|
||||
redirect_tournament_error
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user