#42 Add tests for CommentVoter

This commit is contained in:
2020-03-17 11:20:29 +01:00
parent 60d887c5cc
commit 559adb7e2a
2 changed files with 110 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ class CommentVoter : Voter {
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
return (action is Action)
.and(subject is Comment<*>? || subject is List<*>)
.and(subject is Comment<*>?)
}
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
@@ -27,14 +27,6 @@ class CommentVoter : Voter {
return if (subject.isDeleted()) Vote.DENIED
else Vote.GRANTED
}
if (subject is List<*>) {
subject.forEach {
if (it !is Comment<*> || it.isDeleted()) {
return Vote.DENIED
}
}
return Vote.GRANTED
}
return Vote.DENIED
}