Fix moving a task into the default bucket when moving it between lists
This commit is contained in:
parent
37ebff8752
commit
bc21a21622
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue