1
0

fix(user): allow deleting a user if they have a default project

Resolves https://github.com/go-vikunja/api/issues/78
This commit is contained in:
kolaente
2023-08-23 16:10:51 +02:00
parent 40037f25f2
commit acb03c430e
5 changed files with 44 additions and 3 deletions

View File

@ -58,4 +58,17 @@ func TestDeleteUser(t *testing.T) {
assert.NoError(t, err)
// No assertions for deleted projects since that user doesn't have any
})
t.Run("user with a default project", func(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
notifications.Fake()
u := &user.User{ID: 16}
err := DeleteUser(s, u)
assert.NoError(t, err)
db.AssertMissing(t, "users", map[string]interface{}{"id": u.ID})
db.AssertMissing(t, "projects", map[string]interface{}{"id": 37}) // only user16 had access to this project, and it was their default
})
}