Only check if a bucket limit is exceeded when moving a task between buckets
This commit is contained in:
parent
14d706c91e
commit
ecf09e17a8
2 changed files with 19 additions and 3 deletions
|
@ -787,9 +787,12 @@ func (t *Task) Update() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the bucket limit
|
// Check the bucket limit
|
||||||
if err := checkBucketLimit(s, t, bucket); err != nil {
|
// Only check the bucket limit if the task is being moved between buckets, allow reordering the task within a bucket
|
||||||
_ = s.Rollback()
|
if t.BucketID != ot.BucketID {
|
||||||
return err
|
if err := checkBucketLimit(s, t, bucket); err != nil {
|
||||||
|
_ = s.Rollback()
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the labels
|
// Update the labels
|
||||||
|
|
|
@ -136,6 +136,19 @@ func TestTask_Update(t *testing.T) {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.True(t, IsErrBucketLimitExceeded(err))
|
assert.True(t, IsErrBucketLimitExceeded(err))
|
||||||
})
|
})
|
||||||
|
t.Run("full bucket but not changing the bucket", func(t *testing.T) {
|
||||||
|
db.LoadAndAssertFixtures(t)
|
||||||
|
task := &Task{
|
||||||
|
ID: 4,
|
||||||
|
Title: "test10000",
|
||||||
|
Description: "Lorem Ipsum Dolor",
|
||||||
|
Position: 10,
|
||||||
|
ListID: 1,
|
||||||
|
BucketID: 2, // Bucket 2 already has 3 tasks and a limit of 3
|
||||||
|
}
|
||||||
|
err := task.Update()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTask_Delete(t *testing.T) {
|
func TestTask_Delete(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue