Commit 39426213 authored by Robert Schilling's avatar Robert Schilling

Expose target, filter by state as string

parent fd9cd5ae
...@@ -25,6 +25,7 @@ class TodosFinder ...@@ -25,6 +25,7 @@ class TodosFinder
def execute def execute
items = current_user.todos items = current_user.todos
items = by_action_id(items) items = by_action_id(items)
items = by_action(items)
items = by_author(items) items = by_author(items)
items = by_project(items) items = by_project(items)
items = by_state(items) items = by_state(items)
...@@ -43,6 +44,18 @@ class TodosFinder ...@@ -43,6 +44,18 @@ class TodosFinder
params[:action_id] params[:action_id]
end end
def to_action_id
Todo::ACTION_NAMES.key(action.to_sym)
end
def action?
action.present? && to_action_id
end
def action
params[:action]
end
def author? def author?
params[:author_id].present? params[:author_id].present?
end end
...@@ -96,6 +109,14 @@ class TodosFinder ...@@ -96,6 +109,14 @@ class TodosFinder
params[:type] params[:type]
end end
def by_action(items)
if action?
items = items.where(action: to_action_id)
end
items
end
def by_action_id(items) def by_action_id(items)
if action_id? if action_id?
items = items.where(action: action_id) items = items.where(action: action_id)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
## Get a list of todos ## Get a list of todos
Returns a list of todos. When no filter is applied, it returns all pending todos Returns a list of todos. When no filter is applied, it returns all pending todos
for the current user. Different filters allow the user to for the current user. Different filters allow the user to precise the request.
``` ```
GET /todos GET /todos
...@@ -15,19 +15,11 @@ Parameters: ...@@ -15,19 +15,11 @@ Parameters:
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `action_id` | integer | no | The ID of the action of the todo. See the table below for the ID mapping | | `action` | string | no | The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, or `marked`. |
| `author_id` | integer | no | The ID of an author | | `author_id` | integer | no | The ID of an author |
| `project_id` | integer | no | The ID of a project | | `project_id` | integer | no | The ID of a project |
| `state` | string | no | The state of the todo. Can be either `pending` or `done` | | `state` | string | no | The state of the todo. Can be either `pending` or `done` |
| `type` | string | no | The type of an todo. Can be either `Issue` or `MergeRequest` | | `type` | string | no | The type of a todo. Can be either `Issue` or `MergeRequest` |
| `action_id` | Action |
| ----------- | ------ |
| 1 | Issuable assigned |
| 2 | Mentioned in issuable |
| 3 | Build failed |
| 4 | Todo marked for you |
```bash ```bash
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/todos curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/todos
...@@ -38,64 +30,158 @@ Example Response: ...@@ -38,64 +30,158 @@ Example Response:
```json ```json
[ [
{ {
"id": 130, "id": 102,
"project": { "project": {
"id": 2,
"name": "Gitlab Ce",
"name_with_namespace": "Gitlab Org / Gitlab Ce",
"path": "gitlab-ce",
"path_with_namespace": "gitlab-org/gitlab-ce"
},
"author": {
"name": "Administrator",
"username": "root",
"id": 1, "id": 1,
"name": "Underscore", "state": "active",
"name_with_namespace": "Documentcloud / Underscore", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"path": "underscore", "web_url": "https://gitlab.example.com/u/root"
"path_with_namespace": "documentcloud/underscore"
}, },
"action_name": "marked",
"target_type": "MergeRequest",
"target": {
"id": 34,
"iid": 7,
"project_id": 2,
"title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
"state": "opened",
"created_at": "2016-06-17T07:49:24.419Z",
"updated_at": "2016-06-17T07:52:43.484Z",
"target_branch": "tutorials_git_tricks",
"source_branch": "DNSBL_docs",
"upvotes": 0,
"downvotes": 0,
"author": { "author": {
"name": "Juwan Abbott", "name": "Maxie Medhurst",
"username": "halle", "username": "craig_rutherford",
"id": 8, "id": 12,
"state": "active", "state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0086c7b9e0d73312f32ff745fdcb43e?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/halle" "web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "assigned", "assignee": {
"target_id": 71, "name": "Administrator",
"target_type": "Issue", "username": "root",
"target_reference": "#1", "id": 1,
"target_url": "https://gitlab.example.com/documentcloud/underscore/issues/1", "state": "active",
"body": "At voluptas qui nulla soluta qui et.", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/root"
},
"source_project_id": 2,
"target_project_id": 2,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 32,
"iid": 2,
"project_id": 2,
"title": "v1.0",
"description": "Assumenda placeat ea voluptatem voluptate qui.",
"state": "active",
"created_at": "2016-06-17T07:47:34.163Z",
"updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null
},
"merge_when_build_succeeds": false,
"merge_status": "cannot_be_merged",
"subscribed": true,
"user_notes_count": 7
},
"target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
"body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"state": "pending", "state": "pending",
"created_at": "2016-05-20T20:52:00.626Z" "created_at": "2016-06-17T07:52:35.225Z"
}, },
{ {
"id": 129, "id": 98,
"project": { "project": {
"id": 1, "id": 2,
"name": "Underscore", "name": "Gitlab Ce",
"name_with_namespace": "Documentcloud / Underscore", "name_with_namespace": "Gitlab Org / Gitlab Ce",
"path": "underscore", "path": "gitlab-ce",
"path_with_namespace": "documentcloud/underscore" "path_with_namespace": "gitlab-org/gitlab-ce"
},
"author": {
"name": "Maxie Medhurst",
"username": "craig_rutherford",
"id": 12,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "assigned",
"target_type": "MergeRequest",
"target": {
"id": 34,
"iid": 7,
"project_id": 2,
"title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
"state": "opened",
"created_at": "2016-06-17T07:49:24.419Z",
"updated_at": "2016-06-17T07:52:43.484Z",
"target_branch": "tutorials_git_tricks",
"source_branch": "DNSBL_docs",
"upvotes": 0,
"downvotes": 0,
"author": { "author": {
"name": "Juwan Abbott", "name": "Maxie Medhurst",
"username": "halle", "username": "craig_rutherford",
"id": 8, "id": 12,
"state": "active", "state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0086c7b9e0d73312f32ff745fdcb43e?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/halle" "web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "mentioned", "assignee": {
"target_id": 79, "name": "Administrator",
"target_type": "Issue", "username": "root",
"target_reference": "#9", "id": 1,
"target_url": "https://gitlab.example.com/documentcloud/underscore/issues/9#note_959", "state": "active",
"body": "@root Fix this shit", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/root"
},
"source_project_id": 2,
"target_project_id": 2,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 32,
"iid": 2,
"project_id": 2,
"title": "v1.0",
"description": "Assumenda placeat ea voluptatem voluptate qui.",
"state": "active",
"created_at": "2016-06-17T07:47:34.163Z",
"updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null
},
"merge_when_build_succeeds": false,
"merge_status": "cannot_be_merged",
"subscribed": true,
"user_notes_count": 7
},
"target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
"body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"state": "pending", "state": "pending",
"created_at": "2016-05-20T20:51:51.503Z" "created_at": "2016-06-17T07:49:24.624Z"
} }
] ]
``` ```
## Mark a todo as done ## Mark a todo as done
Marks a single pending todo given by its ID for the current user as done. The to Marks a single pending todo given by its ID for the current user as done. The
marked as done is returned in the response. todo marked as done is returned in the response.
``` ```
DELETE /todos/:id DELETE /todos/:id
...@@ -115,30 +201,77 @@ Example Response: ...@@ -115,30 +201,77 @@ Example Response:
```json ```json
{ {
"id": 130, "id": 102,
"project": { "project": {
"id": 2,
"name": "Gitlab Ce",
"name_with_namespace": "Gitlab Org / Gitlab Ce",
"path": "gitlab-ce",
"path_with_namespace": "gitlab-org/gitlab-ce"
},
"author": {
"name": "Administrator",
"username": "root",
"id": 1, "id": 1,
"name": "Underscore", "state": "active",
"name_with_namespace": "Documentcloud / Underscore", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"path": "underscore", "web_url": "https://gitlab.example.com/u/root"
"path_with_namespace": "documentcloud/underscore"
}, },
"action_name": "marked",
"target_type": "MergeRequest",
"target": {
"id": 34,
"iid": 7,
"project_id": 2,
"title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
"state": "opened",
"created_at": "2016-06-17T07:49:24.419Z",
"updated_at": "2016-06-17T07:52:43.484Z",
"target_branch": "tutorials_git_tricks",
"source_branch": "DNSBL_docs",
"upvotes": 0,
"downvotes": 0,
"author": { "author": {
"name": "Juwan Abbott", "name": "Maxie Medhurst",
"username": "halle", "username": "craig_rutherford",
"id": 8, "id": 12,
"state": "active", "state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0086c7b9e0d73312f32ff745fdcb43e?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/halle" "web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "assigned", "assignee": {
"target_id": 71, "name": "Administrator",
"target_type": "Issue", "username": "root",
"target_reference": "#1", "id": 1,
"target_url": "https://gitlab.example.com/documentcloud/underscore/issues/1", "state": "active",
"body": "At voluptas qui nulla soluta qui et.", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/root"
},
"source_project_id": 2,
"target_project_id": 2,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 32,
"iid": 2,
"project_id": 2,
"title": "v1.0",
"description": "Assumenda placeat ea voluptatem voluptate qui.",
"state": "active",
"created_at": "2016-06-17T07:47:34.163Z",
"updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null
},
"merge_when_build_succeeds": false,
"merge_status": "cannot_be_merged",
"subscribed": true,
"user_notes_count": 7
},
"target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
"body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"state": "done", "state": "done",
"created_at": "2016-05-20T20:52:00.626Z" "created_at": "2016-06-17T07:52:35.225Z"
} }
``` ```
...@@ -160,57 +293,151 @@ Example Response: ...@@ -160,57 +293,151 @@ Example Response:
```json ```json
[ [
{ {
"id": 130, "id": 102,
"project": { "project": {
"id": 2,
"name": "Gitlab Ce",
"name_with_namespace": "Gitlab Org / Gitlab Ce",
"path": "gitlab-ce",
"path_with_namespace": "gitlab-org/gitlab-ce"
},
"author": {
"name": "Administrator",
"username": "root",
"id": 1, "id": 1,
"name": "Underscore", "state": "active",
"name_with_namespace": "Documentcloud / Underscore", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"path": "underscore", "web_url": "https://gitlab.example.com/u/root"
"path_with_namespace": "documentcloud/underscore"
}, },
"action_name": "marked",
"target_type": "MergeRequest",
"target": {
"id": 34,
"iid": 7,
"project_id": 2,
"title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
"state": "opened",
"created_at": "2016-06-17T07:49:24.419Z",
"updated_at": "2016-06-17T07:52:43.484Z",
"target_branch": "tutorials_git_tricks",
"source_branch": "DNSBL_docs",
"upvotes": 0,
"downvotes": 0,
"author": { "author": {
"name": "Juwan Abbott", "name": "Maxie Medhurst",
"username": "halle", "username": "craig_rutherford",
"id": 8, "id": 12,
"state": "active", "state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0086c7b9e0d73312f32ff745fdcb43e?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/halle" "web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "assigned", "assignee": {
"target_id": 71, "name": "Administrator",
"target_type": "Issue", "username": "root",
"target_reference": "#1", "id": 1,
"target_url": "https://gitlab.example.com/documentcloud/underscore/issues/1", "state": "active",
"body": "At voluptas qui nulla soluta qui et.", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/root"
},
"source_project_id": 2,
"target_project_id": 2,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 32,
"iid": 2,
"project_id": 2,
"title": "v1.0",
"description": "Assumenda placeat ea voluptatem voluptate qui.",
"state": "active",
"created_at": "2016-06-17T07:47:34.163Z",
"updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null
},
"merge_when_build_succeeds": false,
"merge_status": "cannot_be_merged",
"subscribed": true,
"user_notes_count": 7
},
"target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
"body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"state": "done", "state": "done",
"created_at": "2016-05-20T20:52:00.626Z" "created_at": "2016-06-17T07:52:35.225Z"
}, },
{ {
"id": 129, "id": 98,
"project": { "project": {
"id": 1, "id": 2,
"name": "Underscore", "name": "Gitlab Ce",
"name_with_namespace": "Documentcloud / Underscore", "name_with_namespace": "Gitlab Org / Gitlab Ce",
"path": "underscore", "path": "gitlab-ce",
"path_with_namespace": "documentcloud/underscore" "path_with_namespace": "gitlab-org/gitlab-ce"
},
"author": {
"name": "Maxie Medhurst",
"username": "craig_rutherford",
"id": 12,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "assigned",
"target_type": "MergeRequest",
"target": {
"id": 34,
"iid": 7,
"project_id": 2,
"title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
"state": "opened",
"created_at": "2016-06-17T07:49:24.419Z",
"updated_at": "2016-06-17T07:52:43.484Z",
"target_branch": "tutorials_git_tricks",
"source_branch": "DNSBL_docs",
"upvotes": 0,
"downvotes": 0,
"author": { "author": {
"name": "Juwan Abbott", "name": "Maxie Medhurst",
"username": "halle", "username": "craig_rutherford",
"id": 8, "id": 12,
"state": "active", "state": "active",
"avatar_url": "http://www.gravatar.com/avatar/a0086c7b9e0d73312f32ff745fdcb43e?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/halle" "web_url": "https://gitlab.example.com/u/craig_rutherford"
}, },
"action_name": "mentioned", "assignee": {
"target_id": 79, "name": "Administrator",
"target_type": "Issue", "username": "root",
"target_reference": "#9", "id": 1,
"target_url": "https://gitlab.example.com/documentcloud/underscore/issues/9#note_959", "state": "active",
"body": "@root Fix this shit", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/root"
},
"source_project_id": 2,
"target_project_id": 2,
"labels": [],
"work_in_progress": false,
"milestone": {
"id": 32,
"iid": 2,
"project_id": 2,
"title": "v1.0",
"description": "Assumenda placeat ea voluptatem voluptate qui.",
"state": "active",
"created_at": "2016-06-17T07:47:34.163Z",
"updated_at": "2016-06-17T07:47:34.163Z",
"due_date": null
},
"merge_when_build_succeeds": false,
"merge_status": "cannot_be_merged",
"subscribed": true,
"user_notes_count": 7
},
"target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
"body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
"state": "done", "state": "done",
"created_at": "2016-05-20T20:51:51.503Z" "created_at": "2016-06-17T07:49:24.624Z"
} },
] ]
``` ```
......
...@@ -277,16 +277,16 @@ module API ...@@ -277,16 +277,16 @@ module API
expose :project, using: Entities::BasicProjectDetails expose :project, using: Entities::BasicProjectDetails
expose :author, using: Entities::UserBasic expose :author, using: Entities::UserBasic
expose :action_name expose :action_name
expose :target_id
expose :target_type expose :target_type
expose :target_reference do |todo, options|
todo.target.to_reference expose :target do |todo, options|
Entities.const_get(todo.target_type).represent(todo.target, options)
end end
expose :target_url do |todo, options| expose :target_url do |todo, options|
target_type = todo.target_type.underscore target_type = todo.target_type.underscore
target_url = "namespace_project_#{target_type}_url" target_url = "namespace_project_#{target_type}_url"
target_anchor = "note_#{todo.note_id}" if todo.note.present? target_anchor = "note_#{todo.note_id}" if todo.note_id?
Gitlab::Application.routes.url_helpers.public_send(target_url, Gitlab::Application.routes.url_helpers.public_send(target_url,
todo.project.namespace, todo.project, todo.target, anchor: target_anchor) todo.project.namespace, todo.project, todo.target, anchor: target_anchor)
......
...@@ -18,7 +18,7 @@ module API ...@@ -18,7 +18,7 @@ module API
get do get do
todos = find_todos todos = find_todos
present paginate(todos), with: Entities::Todo present paginate(todos), with: Entities::Todo, current_user: current_user
end end
# Mark a todo as done # Mark a todo as done
...@@ -33,7 +33,7 @@ module API ...@@ -33,7 +33,7 @@ module API
todo = current_user.todos.find(params[:id]) todo = current_user.todos.find(params[:id])
todo.done todo.done
present todo, with: Entities::Todo present todo, with: Entities::Todo, current_user: current_user
end end
# Mark all todos as done # Mark all todos as done
...@@ -45,7 +45,7 @@ module API ...@@ -45,7 +45,7 @@ module API
todos = find_todos todos = find_todos
todos.each(&:done) todos.each(&:done)
present paginate(Kaminari.paginate_array(todos)), with: Entities::Todo present paginate(Kaminari.paginate_array(todos)), with: Entities::Todo, current_user: current_user
end end
end end
end end
......
...@@ -9,7 +9,7 @@ describe API::Todos, api: true do ...@@ -9,7 +9,7 @@ describe API::Todos, api: true do
let(:author_2) { create(:user) } let(:author_2) { create(:user) }
let(:john_doe) { create(:user, username: 'john_doe') } let(:john_doe) { create(:user, username: 'john_doe') }
let(:merge_request) { create(:merge_request, source_project: project_1) } let(:merge_request) { create(:merge_request, source_project: project_1) }
let!(:pending_1) { create(:todo, project: project_1, author: author_1, user: john_doe) } let!(:pending_1) { create(:todo, :mentioned, project: project_1, author: author_1, user: john_doe) }
let!(:pending_2) { create(:todo, project: project_2, author: author_2, user: john_doe) } let!(:pending_2) { create(:todo, project: project_2, author: author_2, user: john_doe) }
let!(:pending_3) { create(:todo, project: project_1, author: author_2, user: john_doe, target: merge_request) } let!(:pending_3) { create(:todo, project: project_1, author: author_2, user: john_doe, target: merge_request) }
let!(:done) { create(:todo, :done, project: project_1, author: author_1, user: john_doe) } let!(:done) { create(:todo, :done, project: project_1, author: author_1, user: john_doe) }
...@@ -38,9 +38,8 @@ describe API::Todos, api: true do ...@@ -38,9 +38,8 @@ describe API::Todos, api: true do
expect(json_response[0]['id']).to eq(pending_3.id) expect(json_response[0]['id']).to eq(pending_3.id)
expect(json_response[0]['project']).to be_a Hash expect(json_response[0]['project']).to be_a Hash
expect(json_response[0]['author']).to be_a Hash expect(json_response[0]['author']).to be_a Hash
expect(json_response[0]['target_id']).to be_present
expect(json_response[0]['target_type']).to be_present expect(json_response[0]['target_type']).to be_present
expect(json_response[0]['target_reference']).to be_present expect(json_response[0]['target']).to be_a Hash
expect(json_response[0]['target_url']).to be_present expect(json_response[0]['target_url']).to be_present
expect(json_response[0]['body']).to be_present expect(json_response[0]['body']).to be_present
expect(json_response[0]['state']).to eq('pending') expect(json_response[0]['state']).to eq('pending')
...@@ -87,6 +86,16 @@ describe API::Todos, api: true do ...@@ -87,6 +86,16 @@ describe API::Todos, api: true do
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
end end
end end
context 'and using the action filter' do
it 'filters based on action param' do
get api('/todos', john_doe), { action: 'mentioned' }
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
end
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment