#42 Add tests for VoteVoter

This commit is contained in:
2020-03-17 14:21:38 +01:00
parent 622deb0f7d
commit c0becd8fbd
2 changed files with 125 additions and 14 deletions

View File

@@ -10,10 +10,7 @@ class VoteVoter : Voter {
}
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
return action is Action && (
subject is VoteEntity<*>? ||
subject is List<*>
)
return action is Action && subject is VoteEntity<*>?
}
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
@@ -30,16 +27,6 @@ class VoteVoter : Voter {
Vote.GRANTED
}
}
if (subject is List<*>) {
subject.forEach {
if (it !is VoteEntity<*> || it.createdBy.user.id != user.id) {
return Vote.DENIED
}
}
return Vote.GRANTED
}
return Vote.DENIED
}