Commit 20bdfa9c authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '7568-update-epic-is_fixed-column-alone' into 'master'

Resolve "Cannot update Epic is_fixed columns alone in API"

Closes #7568

See merge request gitlab-org/gitlab-ee!7355
parents c9486889 bdfd33a7
......@@ -126,7 +126,12 @@ Example response:
## New epic
Creates a new epic
Creates a new epic.
NOTE: **Note:**
Starting with GitLab [11.3][ee-6448], `start_date` and `end_date` should no longer be assigned
directly, as they now represent composite values. You can configure it via the `*_is_fixed` and
`*_fixed` fields instead.
```
POST /groups/:id/epics
......@@ -138,8 +143,10 @@ POST /groups/:id/epics
| `title` | string | yes | The title of the epic |
| `labels` | string | no | The comma separated list of labels |
| `description` | string | no | The description of the epic |
| `start_date` | string | no | The start date of the epic |
| `end_date` | string. | no | The end date of the epic |
| `start_date_is_fixed` | boolean | no | Whether start date should be sourced from `start_date_fixed` or from milestones (since 11.3) |
| `start_date_fixed` | string | no | The fixed start date of an epic (since 11.3) |
| `due_date_is_fixed` | boolean | no | Whether due date should be sourced from `due_date_fixed` or from milestones (since 11.3) |
| `due_date_fixed` | string | no | The fixed due date of an epic (since 11.3) |
```bash
curl --header POST "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics?title=Epic&description=Epic%20description
......@@ -179,9 +186,12 @@ Example response:
## Update epic
Updates an epic
Updates an epic.
Note that after [11.3][ee-6448], `start_date` and `end_date` should no longer be updated directly, as they now represent composite values. Users can configure via `_is_fixed` and `_fixed` fields instead.
NOTE: **Note:**
Starting with GitLab [11.3][ee-6448], `start_date` and `end_date` should no longer be assigned
directly, as they now represent composite values. You can configure it via the `*_is_fixed` and
`*_fixed` fields instead.
```
PUT /groups/:id/epics/:epic_iid
......@@ -194,9 +204,9 @@ PUT /groups/:id/epics/:epic_iid
| `title` | string | no | The title of an epic |
| `description` | string | no | The description of an epic |
| `labels` | string | no | The comma separated list of labels |
| `start_date_is_fixed` | boolean | no | Whether start date should be sourced from `start_date_fixed` (since 11.3) |
| `start_date_is_fixed` | boolean | no | Whether start date should be sourced from `start_date_fixed` or from milestones (since 11.3) |
| `start_date_fixed` | string | no | The fixed start date of an epic (since 11.3) |
| `due_date_is_fixed` | boolean | no | Whether due date should be sourced from `due_date_fixed` (since 11.3) |
| `due_date_is_fixed` | boolean | no | Whether due date should be sourced from `due_date_fixed` or from milestones (since 11.3) |
| `due_date_fixed` | string | no | The fixed due date of an epic (since 11.3) |
```bash
......
......@@ -112,7 +112,7 @@ module API
optional :end_date, as: :due_date_fixed, type: String, desc: 'The due date of an epic'
optional :due_date_is_fixed, type: Boolean, desc: 'Indicates due date should be sourced from due_date_fixed field not the issue milestones'
optional :labels, type: String, desc: 'Comma-separated list of label names'
at_least_one_of :title, :description, :start_date_fixed, :due_date_fixed, :labels
at_least_one_of :title, :description, :start_date_fixed, :start_date_is_fixed, :due_date_fixed, :due_date_is_fixed, :labels
end
put ':id/(-/)epics/:epic_iid' do
authorize_can_admin!
......
......@@ -197,7 +197,15 @@ describe API::Epics do
describe 'POST /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/epics" }
let(:params) { { title: 'new epic', description: 'epic description', labels: 'label1' } }
let(:params) do
{
title: 'new epic',
description: 'epic description',
labels: 'label1',
due_date_fixed: '2018-07-17',
due_date_is_fixed: true
}
end
it_behaves_like 'error requests'
......@@ -236,6 +244,10 @@ describe API::Epics do
expect(epic.title).to eq('new epic')
expect(epic.description).to eq('epic description')
expect(epic.start_date_fixed).to eq(nil)
expect(epic.start_date_is_fixed).to be_falsey
expect(epic.due_date_fixed).to eq(Date.new(2018, 7, 17))
expect(epic.due_date_is_fixed).to eq(true)
expect(epic.labels.first.title).to eq('label1')
end
......@@ -308,6 +320,8 @@ describe API::Epics do
expect(result.start_date).to eq(Date.new(2018, 7, 17))
expect(result.start_date_fixed).to eq(Date.new(2018, 7, 17))
expect(result.start_date_is_fixed).to eq(true)
expect(result.due_date_fixed).to eq(nil)
expect(result.due_date_is_fixed).to be_falsey
end
context 'when deprecated start_date and end_date params are present' do
......@@ -323,6 +337,19 @@ describe API::Epics do
expect(result.due_date_fixed).to eq(new_due_date)
end
end
context 'when updating start_date_is_fixed by itself' do
let(:epic) { create(:epic, :use_fixed_dates, group: group) }
let(:new_start_date) { epic.start_date + 1.day }
let(:new_due_date) { epic.end_date + 1.day }
let!(:params) { { start_date_is_fixed: false } }
it 'updates start_date_is_fixed' do
result = epic.reload
expect(result.start_date_is_fixed).to eq(false)
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