mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Fixed the POSt endpoint to accept bracket positions
This commit is contained in:
@@ -68,7 +68,6 @@ class MatAssignmentRulesController < ApplicationController
|
||||
# Permit the parameters and convert specific fields to integer arrays
|
||||
params.require(:mat_assignment_rule).permit(:mat_id, weight_classes: [], bracket_positions: [], rounds: []).tap do |whitelisted|
|
||||
whitelisted[:weight_classes] = whitelisted[:weight_classes].map(&:to_i)
|
||||
whitelisted[:bracket_positions] = whitelisted[:bracket_positions].map(&:to_i)
|
||||
whitelisted[:rounds] = whitelisted[:rounds].map(&:to_i)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -200,4 +200,19 @@ class MatAssignmentRulesControllerTest < ActionController::TestCase
|
||||
end
|
||||
redirect
|
||||
end
|
||||
|
||||
test "logged in tournament owner should create a rule with bracket positions" do
|
||||
sign_in_owner
|
||||
assert_difference 'MatAssignmentRule.count', 1 do
|
||||
post :create, params: { tournament_id: @tournament.id, mat_assignment_rule: {
|
||||
mat_id: @mat.id, weight_classes: [1, 2, 3], bracket_positions: ['A1', 'B2'], rounds: [1, 2]
|
||||
} }
|
||||
end
|
||||
assert_redirected_to tournament_mat_assignment_rules_path(@tournament)
|
||||
|
||||
rule = MatAssignmentRule.last
|
||||
assert_equal [1, 2, 3], rule.weight_classes
|
||||
assert_equal ['A1', 'B2'], rule.bracket_positions
|
||||
assert_equal [1, 2], rule.rounds
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user