Commit f7b24bd1 authored by Jarka Košanová's avatar Jarka Košanová

Fix creating epics with dates from api

- set start_date and end_date if dates are fixed
parent 92c346f6
---
title: Fix creating epics with dates from api
merge_request: 18393
author:
type: fixed
......@@ -20,7 +20,17 @@ module Epics
end
def whitelisted_epic_params
params.slice(:title, :description, :start_date, :end_date, :milestone, :label_ids, :parent_id)
result = params.slice(:title, :description, :label_ids, :parent_id)
if params[:start_date_fixed] && params[:start_date_is_fixed]
result[:start_date] = params[:start_date_fixed]
end
if params[:due_date_fixed] && params[:due_date_is_fixed]
result[:end_date] = params[:due_date_fixed]
end
result
end
end
end
......@@ -491,6 +491,7 @@ describe API::Epics do
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).to eq(Date.new(2018, 7, 17))
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')
......
......@@ -25,4 +25,19 @@ describe Epics::CreateService do
expect(NewEpicWorker).to have_received(:perform_async).with(epic.id, user.id)
end
end
context 'handling fixed dates' do
it 'sets the fixed date correctly' do
date = Date.new(2019, 10, 10)
params[:start_date_fixed] = date
params[:start_date_is_fixed] = true
subject
epic = Epic.last
expect(epic.start_date).to eq(date)
expect(epic.start_date_fixed).to eq(date)
expect(epic.start_date_is_fixed).to be_truthy
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