Skip to content

Commit

Permalink
Insert validation that token divider must be > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
kjw142857 committed Nov 16, 2023
1 parent 2b648c3 commit 4537fc0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/cadet/assessments/question_types/voting_question.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ defmodule Cadet.Assessments.QuestionTypes.VotingQuestion do
question
|> cast(params, @required_fields ++ @optional_fields)
|> validate_required(@required_fields)
|> validate_number(:token_divider, greater_than: 0)
end
end
20 changes: 20 additions & 0 deletions test/cadet/assessments/question_types/voting_question_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ defmodule Cadet.Assessments.QuestionTypes.VotingQuestionTest do
},
:invalid
)

assert_changeset(
%{
content: "content",
contest_number: "C3",
reveal_hours: 48,
token_divider: -1
},
:invalid
)

assert_changeset(
%{
content: "content",
contest_number: "C6",
reveal_hours: 48,
token_divider: 0
},
:invalid
)
end
end
end

0 comments on commit 4537fc0

Please sign in to comment.