Make a task done when it is moved to the done bucket

This commit is contained in:
kolaente 2021-03-21 22:12:42 +01:00
parent fc92fd3325
commit 37ebff8752
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 32 additions and 0 deletions

View File

@ -16,6 +16,7 @@
title: testbucket3
list_id: 1
created_by_id: 1
is_done_bucket: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
- id: 4

View File

@ -970,6 +970,10 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) {
}
}
if bucket.IsDoneBucket {
t.Done = true
}
// Update the labels
//
// Maybe FIXME:

View File

@ -218,8 +218,35 @@ func TestTask_Update(t *testing.T) {
assert.Error(t, err)
assert.True(t, IsErrBucketDoesNotBelongToList(err))
})
t.Run("moving a task to the done bucket", func(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
task := &Task{
ID: 1,
Title: "test",
ListID: 1,
BucketID: 3, // Bucket 3 is the done bucket
}
err := task.Update(s, u)
assert.NoError(t, err)
err = s.Commit()
assert.NoError(t, err)
assert.True(t, task.Done)
db.AssertExists(t, "tasks", map[string]interface{}{
"id": 1,
"done": true,
"title": "test",
"list_id": 1,
"bucket_id": 3,
}, false)
})
}
// TODO: Add test to assert moving a task between lists assigns it the default bucket of the new list + done bucket (-> If the default bucket of the new list is the done bucket)
func TestTask_Delete(t *testing.T) {
t.Run("normal", func(t *testing.T) {
db.LoadAndAssertFixtures(t)