Commit 4a9370d7 authored by Felipe Artur's avatar Felipe Artur

Accept issue weight greater than or equal to zero

This updates the API to accept the same issue weight values that UI app accepts.
parent 7c12cb90
...@@ -478,7 +478,7 @@ POST /projects/:id/issues ...@@ -478,7 +478,7 @@ POST /projects/:id/issues
| `due_date` | string | no | Date time string in the format YEAR-MONTH-DAY, e.g. `2016-03-11` | | `due_date` | string | no | Date time string in the format YEAR-MONTH-DAY, e.g. `2016-03-11` |
| `merge_request_to_resolve_discussions_of` | integer | no | The IID of a merge request in which to resolve all issues. This will fill the issue with a default description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values.| | `merge_request_to_resolve_discussions_of` | integer | no | The IID of a merge request in which to resolve all issues. This will fill the issue with a default description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values.|
| `discussion_to_resolve` | string | no | The ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved. Use in combination with `merge_request_to_resolve_discussions_of`. | | `discussion_to_resolve` | string | no | The ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved. Use in combination with `merge_request_to_resolve_discussions_of`. |
| `weight` | integer | no | The weight of the issue in range 0 to 9 | | `weight` | integer | no | The weight of the issue. Valid values are greater than or equal to 0. |
```bash ```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug
...@@ -560,7 +560,7 @@ PUT /projects/:id/issues/:issue_iid ...@@ -560,7 +560,7 @@ PUT /projects/:id/issues/:issue_iid
| `state_event` | string | no | The state event of an issue. Set `close` to close the issue and `reopen` to reopen it | | `state_event` | string | no | The state event of an issue. Set `close` to close the issue and `reopen` to reopen it |
| `updated_at` | string | no | Date time string, ISO 8601 formatted, e.g. `2016-03-11T03:45:40Z` (requires admin or project owner rights) | | `updated_at` | string | no | Date time string, ISO 8601 formatted, e.g. `2016-03-11T03:45:40Z` (requires admin or project owner rights) |
| `due_date` | string | no | Date time string in the format YEAR-MONTH-DAY, e.g. `2016-03-11` | | `due_date` | string | no | Date time string in the format YEAR-MONTH-DAY, e.g. `2016-03-11` |
| `weight` | integer | no | The weight of the issue in range 0 to 9 | | `weight` | integer | no | The weight of the issue. Valid values are greater than or equal to 0. 0 |
| `discussion_locked` | boolean | no | Flag indicating if the issue's discussion is locked. If the discussion is locked only project members can add or edit comments. | | `discussion_locked` | boolean | no | Flag indicating if the issue's discussion is locked. If the discussion is locked only project members can add or edit comments. |
```bash ```bash
......
...@@ -87,9 +87,7 @@ but they are immediately available to all projects in the group. ...@@ -87,9 +87,7 @@ but they are immediately available to all projects in the group.
if the label doesn't exist yet, when you click **Edit**, it opens a dropdown menu from which you can select **Create new label**. if the label doesn't exist yet, when you click **Edit**, it opens a dropdown menu from which you can select **Create new label**.
#### 8. Weight **[STARTER]** #### 8. Weight **[STARTER]**
- Assign a weight. Larger values are used to indicate more effort is required to complete the issue. Only positive values or zero are allowed.
- Attribute a weight (in a 0 to 9 range) to that issue. Easy to complete
should weight 1 and very hard to complete should weight 9.
Learn more on the [Issue Weight documentation](../../../workflow/issue_weight.md). Learn more on the [Issue Weight documentation](../../../workflow/issue_weight.md).
......
...@@ -82,10 +82,6 @@ module EE ...@@ -82,10 +82,6 @@ module EE
end end
end end
def weight_filter_options
WEIGHT_RANGE.to_a
end
def weight_options def weight_options
[WEIGHT_NONE] + WEIGHT_RANGE.to_a [WEIGHT_NONE] + WEIGHT_RANGE.to_a
end end
......
---
title: 'API: Allow issue weight parameter to be greater than or equal to zero'
merge_request:
author:
type: other
...@@ -42,7 +42,7 @@ describe API::Issues, :mailer do ...@@ -42,7 +42,7 @@ describe API::Issues, :mailer do
describe "POST /projects/:id/issues" do describe "POST /projects/:id/issues" do
it 'creates a new project issue' do it 'creates a new project issue' do
post api("/projects/#{project.id}/issues", user), post api("/projects/#{project.id}/issues", user),
title: 'new issue', labels: 'label, label2', weight: 3, title: 'new issue', labels: 'label, label2', weight: 101,
assignee_ids: [user2.id] assignee_ids: [user2.id]
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
...@@ -50,7 +50,7 @@ describe API::Issues, :mailer do ...@@ -50,7 +50,7 @@ describe API::Issues, :mailer do
expect(json_response['description']).to be_nil expect(json_response['description']).to be_nil
expect(json_response['labels']).to eq(%w(label label2)) expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
expect(json_response['weight']).to eq(3) expect(json_response['weight']).to eq(101)
expect(json_response['assignee']['name']).to eq(user2.name) expect(json_response['assignee']['name']).to eq(user2.name)
expect(json_response['assignees'].first['name']).to eq(user2.name) expect(json_response['assignees'].first['name']).to eq(user2.name)
end end
...@@ -58,10 +58,10 @@ describe API::Issues, :mailer do ...@@ -58,10 +58,10 @@ describe API::Issues, :mailer do
describe 'PUT /projects/:id/issues/:issue_id to update weight' do describe 'PUT /projects/:id/issues/:issue_id to update weight' do
it 'updates an issue with no weight' do it 'updates an issue with no weight' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), weight: 5 put api("/projects/#{project.id}/issues/#{issue.iid}", user), weight: 101
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response['weight']).to eq(5) expect(json_response['weight']).to eq(101)
end end
it 'removes a weight from an issue' do it 'removes a weight from an issue' do
...@@ -77,14 +77,7 @@ describe API::Issues, :mailer do ...@@ -77,14 +77,7 @@ describe API::Issues, :mailer do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), weight: -1 put api("/projects/#{project.id}/issues/#{issue.iid}", user), weight: -1
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
expect(json_response['error']).to eq('weight does not have a valid value') expect(json_response['message']['weight']).to be_present
end
it 'returns 400 if weight is more than maximum weight' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), weight: 10
expect(response).to have_gitlab_http_status(400)
expect(json_response['error']).to eq('weight does not have a valid value')
end end
it 'adds a note when the weight is changed' do it 'adds a note when the weight is changed' do
......
...@@ -55,7 +55,7 @@ module API ...@@ -55,7 +55,7 @@ module API
end end
params :issue_params_ee do params :issue_params_ee do
optional :weight, type: Integer, values: 0..9, desc: 'The weight of the issue' optional :weight, type: Integer, desc: 'The weight of the issue'
end end
params :issue_params do params :issue_params do
......
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