Skip to content
This repository was archived by the owner on Apr 27, 2023. It is now read-only.

Commit de9298d

Browse files
committed
test case for deleta a user and should not show in the list
1 parent 5411669 commit de9298d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

codebrag-dao/src/test/scala/com/softwaremill/codebrag/dao/user/UserDAOSpec.scala

+18
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,24 @@ class SQLUserDAOSpec extends FlatSpecWithSQL with ClearSQLDataAfterTest with Bef
384384
// then
385385
assert(deletedUser === None , "Deletion was attempted but found " + deletedUser)
386386
}
387+
it should "deleta a user and should not show in the list " taggedAs RequiresDb in {
388+
// given
389+
val user = UserAssembler.randomUser.withBasicAuth("user", "pass").withAdmin(set = false).withActive(set = false).get
390+
userDAO.add(user)
391+
val newAuth = Authentication.basic(user.authentication.username, "newpass")
392+
393+
// when
394+
val tobeDeletedUser = user.copy(authentication = newAuth, admin = true, active = true)
395+
val userCountBeforeDelete = userDAO.findAll().length
396+
userDAO.delete(tobeDeletedUser.id)
397+
val deletedUser = userDAO.findById(user.id)
398+
val userCountAfterDelete = userDAO.findAll().length
399+
// then
400+
assert(deletedUser === None , "Deletion was attempted but found " + deletedUser)
401+
userCountAfterDelete should be(userCountBeforeDelete -1)
402+
403+
}
404+
387405
"rememberNotifications" should "store dates properly" taggedAs RequiresDb in {
388406
// given
389407
val user = UserAssembler.randomUser.get

0 commit comments

Comments
 (0)