Verified Commit f822349c authored by James Hebden's avatar James Hebden ✨ Committed by GitLab
Browse files

feat(todos): add Group field to Todo

Changelog: Improvements
parent 23eb0a84
Loading
Loading
Loading
Loading
+17 −0
Changes for testdata/list_todos.json: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,5 +14,22 @@
      "id": "1d76d1b2e3e886108f662765c97f4687f4134d8c",
      "approvals_before_merge": null
    }
  },
  {
    "id": 3,
    "state": "pending",
    "group": {
      "id": 1,
      "name": "gitlab-org",
      "path": "gitlab-org",
      "kind": "group",
      "full_path": "gitlab-org",
      "parent_id": null,
      "avatar_url": null,
      "web_url": "https://gitlab.example.com/groups/gitlab-org"
    },
    "target": {
      "id": 2
    }
  }
]
+2 −0
Changes for todos.go: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ var _ TodosServiceInterface = (*TodosService)(nil)
type Todo struct {
	ID         int64             `json:"id"`
	Project    *BasicProject     `json:"project"`
	Group      *ProjectNamespace `json:"group"`
	Author     *BasicUser        `json:"author"`
	ActionName TodoAction        `json:"action_name"`
	TargetType TodoTargetType    `json:"target_type"`
@@ -70,6 +71,7 @@ type Todo struct {
	Body       string            `json:"body"`
	State      string            `json:"state"`
	CreatedAt  *time.Time        `json:"created_at"`
	UpdatedAt  *time.Time        `json:"updated_at"`
}

func (t Todo) String() string {
+13 −0
Changes for todos_test.go: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -135,6 +135,19 @@ func TestListTodos(t *testing.T) {
			want := []*Todo{
				{ID: 1, State: "pending", Target: &TodoTarget{ID: float64(1), ApprovalsBeforeMerge: 2}},
				{ID: 2, State: "pending", Target: &TodoTarget{ID: "1d76d1b2e3e886108f662765c97f4687f4134d8c"}},
				{
					ID:    3,
					State: "pending",
					Group: &ProjectNamespace{
						ID:       1,
						Name:     "gitlab-org",
						Path:     "gitlab-org",
						Kind:     "group",
						FullPath: "gitlab-org",
						WebURL:   "https://gitlab.example.com/groups/gitlab-org",
					},
					Target: &TodoTarget{ID: float64(2)},
				},
			}

			require.Equal(t, want, todos)