Add validation on route PutVoteOnComment
This commit is contained in:
@@ -181,4 +181,39 @@ class `Vote routes` : BaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
@Tag("BadRequest")
|
||||
fun `I cannot vote comment with wrong request`(): List<DynamicTest> {
|
||||
withIntegrationApplication {
|
||||
`Given I have citizen`("Antoine", "Lavoisier")
|
||||
`Given I have article`(id = "835c5101-ca39-4038-a4e6-da6ee62ca6d5")
|
||||
`Given I have comment on article`(
|
||||
createdBy = Name("Antoine", "Lavoisier"),
|
||||
article = "835c5101-ca39-4038-a4e6-da6ee62ca6d5",
|
||||
id = "e793eccc-456b-4450-a292-46d592229b74",
|
||||
)
|
||||
}
|
||||
|
||||
return listOf(-10, -2, +2, +10).map { note ->
|
||||
DynamicTest.dynamicTest("""I can vote comment with note "$note"""") {
|
||||
withIntegrationApplication {
|
||||
`When I send a PUT request`("/comments/e793eccc-456b-4450-a292-46d592229b74/vote", ALL - REQUEST_BODY) {
|
||||
`authenticated as`("Antoine", "Lavoisier")
|
||||
`with body`(
|
||||
"""
|
||||
{
|
||||
"note": $note
|
||||
}
|
||||
"""
|
||||
)
|
||||
} `Then the response should be` BadRequest and {
|
||||
`And the response should not be null`()
|
||||
`And the response should contain`("$.invalidParams[0].name", ".note")
|
||||
`And the response should contain`("$.invalidParams[0].reason", if (note > 0) "must be at most '1'" else "must be at least '-1'")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user