Commit 09ba3e45 authored by gaga5lala's avatar gaga5lala

REFACTOR: fix code review comments

- omit action_id and target_id
- follow api to use String type for action param
- update todo api doc
- rspec rewording
parent d40f9294
...@@ -21,12 +21,12 @@ Parameters: ...@@ -21,12 +21,12 @@ Parameters:
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `action` | string | no | The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, `approval_required`, `unmergeable` or `directly_addressed`. | | `action` | string | no | The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, `approval_required`, `unmergeable`, `directly_addressed` or `merge_train_removed`. |
| `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 |
| `group_id` | integer | no | The ID of a group | | `group_id` | integer | no | The ID of a group |
| `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 a todo. Can be either `Issue` or `MergeRequest` | | `type` | string | no | The type of a todo. Can be either `Issue`, `MergeRequest`, `DesignManagement::Design` or `AlertManagement::Alert` |
```shell ```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/todos" curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/todos"
......
...@@ -40,11 +40,9 @@ module API ...@@ -40,11 +40,9 @@ module API
resource :todos do resource :todos do
helpers do helpers do
params :todo_filters do params :todo_filters do
optional :action_id, Integer optional :action, String, values: Todo::ACTION_NAMES.values.map(&:to_s)
optional :action, Array[String], values: Todo::ACTION_NAMES.values.map(&:to_s)
optional :author_id, Integer optional :author_id, Integer
optional :state, String, values: Todo.state_machine.states.map(&:name).map(&:to_s) optional :state, String, values: Todo.state_machine.states.map(&:name).map(&:to_s)
optional :target_id, Integer
optional :type, Array[String], values: TodosFinder.todo_types optional :type, Array[String], values: TodosFinder.todo_types
optional :project_id, Integer optional :project_id, Integer
optional :group_id, Integer optional :group_id, Integer
......
...@@ -36,7 +36,7 @@ RSpec.describe API::Todos do ...@@ -36,7 +36,7 @@ RSpec.describe API::Todos do
context 'when authenticated' do context 'when authenticated' do
context 'when invalid params' do context 'when invalid params' do
context "invalid action" do context "invalid action" do
it 'returns argument error' do it 'returns 400' do
get api('/todos', john_doe), params: { action: 'InvalidAction' } get api('/todos', john_doe), params: { action: 'InvalidAction' }
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
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