diff --git a/pkg/db/fixtures/buckets.yml b/pkg/db/fixtures/buckets.yml index 92c25cf7a94..64d3b037e54 100644 --- a/pkg/db/fixtures/buckets.yml +++ b/pkg/db/fixtures/buckets.yml @@ -3,7 +3,7 @@ list_id: 1 created_by_id: 1 limit: 9999999 # This bucket has a limit we will never exceed in the tests to make sure the logic allows for buckets with limits - position: 2 + position: 1 created: 2020-04-18 21:13:52 updated: 2020-04-18 21:13:52 - id: 2 @@ -11,7 +11,7 @@ list_id: 1 created_by_id: 1 limit: 3 - position: 1 + position: 2 created: 2020-04-18 21:13:52 updated: 2020-04-18 21:13:52 - id: 3 diff --git a/pkg/models/kanban.go b/pkg/models/kanban.go index ff4eb20933d..75a0a9f58e1 100644 --- a/pkg/models/kanban.go +++ b/pkg/models/kanban.go @@ -81,7 +81,7 @@ func getDefaultBucket(s *xorm.Session, listID int64) (bucket *Bucket, err error) bucket = &Bucket{} _, err = s. Where("list_id = ?", listID). - OrderBy("id asc"). + OrderBy("position asc"). Get(bucket) return } diff --git a/pkg/models/kanban_test.go b/pkg/models/kanban_test.go index 079da0f408c..ae91f58bba1 100644 --- a/pkg/models/kanban_test.go +++ b/pkg/models/kanban_test.go @@ -49,22 +49,22 @@ func TestBucket_ReadAll(t *testing.T) { assert.Len(t, buckets, 3) // Assert all tasks are in the right bucket - assert.Len(t, buckets[0].Tasks, 3) - assert.Len(t, buckets[1].Tasks, 12) + assert.Len(t, buckets[0].Tasks, 12) + assert.Len(t, buckets[1].Tasks, 3) assert.Len(t, buckets[2].Tasks, 3) // Assert we have bucket 1, 2, 3 but not 4 (that belongs to a different list) and their position - assert.Equal(t, int64(2), buckets[0].ID) - assert.Equal(t, int64(1), buckets[1].ID) + assert.Equal(t, int64(1), buckets[0].ID) + assert.Equal(t, int64(2), buckets[1].ID) assert.Equal(t, int64(3), buckets[2].ID) // Kinda assert all tasks are in the right buckets - assert.Equal(t, int64(1), buckets[1].Tasks[0].BucketID) - assert.Equal(t, int64(1), buckets[1].Tasks[1].BucketID) + assert.Equal(t, int64(1), buckets[0].Tasks[0].BucketID) + assert.Equal(t, int64(1), buckets[0].Tasks[1].BucketID) - assert.Equal(t, int64(2), buckets[0].Tasks[0].BucketID) - assert.Equal(t, int64(2), buckets[0].Tasks[1].BucketID) - assert.Equal(t, int64(2), buckets[0].Tasks[2].BucketID) + assert.Equal(t, int64(2), buckets[1].Tasks[0].BucketID) + assert.Equal(t, int64(2), buckets[1].Tasks[1].BucketID) + assert.Equal(t, int64(2), buckets[1].Tasks[2].BucketID) assert.Equal(t, int64(3), buckets[2].Tasks[0].BucketID) assert.Equal(t, int64(3), buckets[2].Tasks[1].BucketID) @@ -89,8 +89,8 @@ func TestBucket_ReadAll(t *testing.T) { buckets := bucketsInterface.([]*Bucket) assert.Len(t, buckets, 3) - assert.Equal(t, int64(2), buckets[1].Tasks[0].ID) - assert.Equal(t, int64(33), buckets[1].Tasks[1].ID) + assert.Equal(t, int64(2), buckets[0].Tasks[0].ID) + assert.Equal(t, int64(33), buckets[0].Tasks[1].ID) }) t.Run("accessed by link share", func(t *testing.T) { db.LoadAndAssertFixtures(t)