Fix moving a task into the default bucket when moving it between lists

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

View File

@ -23,6 +23,7 @@
title: testbucket4 - other list
list_id: 2
created_by_id: 1
is_done_bucket: 1
created: 2020-04-18 21:13:52
updated: 2020-04-18 21:13:52
# The following are not or only partly owned by user 1

View File

@ -945,7 +945,7 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) {
}
// If there is a bucket set, make sure they belong to the same list as the task
err = checkBucketAndTaskBelongToSameList(s, &ot, bucket)
err = checkBucketAndTaskBelongToSameList(s, t, bucket)
if err != nil {
return
}

View File

@ -243,9 +243,24 @@ func TestTask_Update(t *testing.T) {
"bucket_id": 3,
}, false)
})
}
t.Run("default bucket when moving a task between lists", func(t *testing.T) {
db.LoadAndAssertFixtures(t)
s := db.NewSession()
defer s.Close()
// 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)
task := &Task{
ID: 1,
ListID: 2,
}
err := task.Update(s, u)
assert.NoError(t, err)
err = s.Commit()
assert.NoError(t, err)
assert.Equal(t, int64(4), task.BucketID) // bucket 4 is the default bucket on list 2
assert.True(t, task.Done) // bucket 4 is the done bucket, so the task should be marked as done as well
})
}
func TestTask_Delete(t *testing.T) {
t.Run("normal", func(t *testing.T) {