Commit bad81180 authored by Mark Chao's avatar Mark Chao

Update API for epic dates to utilize milestones dates

Expose new date fields.
Translate start_date and end_date params as '_fixed' for backward compatibility.
parent 06bb783f
...@@ -79,8 +79,10 @@ module API ...@@ -79,8 +79,10 @@ module API
params do params do
requires :title, type: String, desc: 'The title of an epic' requires :title, type: String, desc: 'The title of an epic'
optional :description, type: String, desc: 'The description of an epic' optional :description, type: String, desc: 'The description of an epic'
optional :start_date, type: String, desc: 'The start date of an epic' optional :start_date, as: :start_date_fixed, type: String, desc: 'The start date of an epic'
optional :end_date, type: String, desc: 'The end date of an epic' optional :start_date_is_fixed, type: Boolean, desc: 'Indicates start date should be sourced from start_date_fixed field not the issue milestones'
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' optional :labels, type: String, desc: 'Comma-separated list of label names'
end end
post ':id/(-/)epics' do post ':id/(-/)epics' do
...@@ -101,10 +103,12 @@ module API ...@@ -101,10 +103,12 @@ module API
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic' requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
optional :title, type: String, desc: 'The title of an epic' optional :title, type: String, desc: 'The title of an epic'
optional :description, type: String, desc: 'The description of an epic' optional :description, type: String, desc: 'The description of an epic'
optional :start_date, type: String, desc: 'The start date of an epic' optional :start_date, as: :start_date_fixed, type: String, desc: 'The start date of an epic'
optional :end_date, type: String, desc: 'The end date of an epic' optional :start_date_is_fixed, type: Boolean, desc: 'Indicates start date should be sourced from start_date_fixed field not the issue milestones'
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' optional :labels, type: String, desc: 'Comma-separated list of label names'
at_least_one_of :title, :description, :start_date, :end_date, :labels at_least_one_of :title, :description, :start_date_fixed, :due_date_fixed, :labels
end end
put ':id/(-/)epics/:epic_iid' do put ':id/(-/)epics/:epic_iid' do
authorize_can_admin! authorize_can_admin!
......
...@@ -162,7 +162,14 @@ module EE ...@@ -162,7 +162,14 @@ module EE
expose :description expose :description
expose :author, using: ::API::Entities::UserBasic expose :author, using: ::API::Entities::UserBasic
expose :start_date expose :start_date
expose :end_date expose :start_date_is_fixed?, as: :start_date_is_fixed
expose :start_date_fixed
expose :start_date_from_milestones
expose :end_date # @deprecated
expose :end_date, as: :due_date
expose :due_date_is_fixed?, as: :due_date_is_fixed
expose :due_date_fixed
expose :due_date_from_milestones
expose :created_at expose :created_at
expose :updated_at expose :updated_at
expose :labels do |epic, options| expose :labels do |epic, options|
......
...@@ -25,7 +25,14 @@ ...@@ -25,7 +25,14 @@
} }
}, },
"start_date": { "type": ["string", "null"] }, "start_date": { "type": ["string", "null"] },
"start_date_fixed": { "type": ["string", "null"] },
"start_date_from_milestones": { "type": ["string", "null"] },
"start_date_is_fixed": { "type": ["boolean"] },
"end_date": { "type": ["string", "null"] }, "end_date": { "type": ["string", "null"] },
"due_date": { "type": ["string", "null"] },
"due_date_fixed": { "type": ["string", "null"] },
"due_date_from_milestones": { "type": ["string", "null"] },
"due_date_is_fixed": { "type": ["boolean"] },
"created_at": { "type": ["string", "null"] }, "created_at": { "type": ["string", "null"] },
"updated_at": { "type": ["string", "null"] } "updated_at": { "type": ["string", "null"] }
}, },
......
...@@ -19,7 +19,14 @@ ...@@ -19,7 +19,14 @@
"description": { "type": ["string", "null"] }, "description": { "type": ["string", "null"] },
"author": { "type": ["object", "null"] }, "author": { "type": ["object", "null"] },
"start_date": { "type": ["string", "null"] }, "start_date": { "type": ["string", "null"] },
"start_date_fixed": { "type": ["string", "null"] },
"start_date_from_milestones": { "type": ["string", "null"] },
"start_date_is_fixed": { "type": ["boolean"] },
"end_date": { "type": ["string", "null"] }, "end_date": { "type": ["string", "null"] },
"due_date": { "type": ["string", "null"] },
"due_date_fixed": { "type": ["string", "null"] },
"due_date_from_milestones": { "type": ["string", "null"] },
"due_date_is_fixed": { "type": ["boolean"] },
"created_at": { "type": ["string", "null"] }, "created_at": { "type": ["string", "null"] },
"updated_at": { "type": ["string", "null"] }, "updated_at": { "type": ["string", "null"] },
"labels": { "labels": {
......
...@@ -206,6 +206,19 @@ describe API::Epics do ...@@ -206,6 +206,19 @@ describe API::Epics do
expect(epic.description).to eq('epic description') expect(epic.description).to eq('epic description')
expect(epic.labels.first.title).to eq('label1') expect(epic.labels.first.title).to eq('label1')
end end
context 'when deprecated start_date and end_date params are present' do
let(:start_date) { Date.new(2001, 1, 1) }
let(:due_date) { Date.new(2001, 1, 2) }
let(:params) { { title: 'new epic', start_date: start_date, end_date: due_date } }
it 'updates start_date_fixed and due_date_fixed' do
result = Epic.last
expect(result.start_date_fixed).to eq(start_date)
expect(result.due_date_fixed).to eq(due_date)
end
end
end end
end end
end end
...@@ -261,6 +274,20 @@ describe API::Epics do ...@@ -261,6 +274,20 @@ describe API::Epics do
expect(result.description).to eq('new description') expect(result.description).to eq('new description')
expect(result.labels.first.title).to eq('label2') expect(result.labels.first.title).to eq('label2')
end end
context 'when deprecated start_date and end_date params are present' 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: new_start_date, end_date: new_due_date } }
it 'updates start_date_fixed and due_date_fixed' do
result = epic.reload
expect(result.start_date_fixed).to eq(new_start_date)
expect(result.due_date_fixed).to eq(new_due_date)
end
end
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