Commit 10f4df58 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch...

Merge branch '11750-epic-dates-from-milestones-don-t-work-when-using-epic-in-a-new-issue' into 'master'

Resolve "Epic dates from milestones don't work when using /epic in a new issue"

See merge request gitlab-org/gitlab-ee!15062
parents cbf8c657 06a5174c
......@@ -49,3 +49,5 @@ module Issues
end
end
end
Issues::CreateService.prepend_if_ee('EE::Issues::CreateService')
# frozen_string_literal: true
module EE
module Issues
module CreateService
extend ::Gitlab::Utils::Override
override :before_create
def before_create(issue)
handle_issue_epic_link(issue)
super
end
def handle_issue_epic_link(issue)
return unless params.key?(:epic)
epic_param = params.delete(:epic)
if epic_param
EpicIssues::CreateService.new(epic_param, current_user, { target_issuable: issue }).execute
else
link = EpicIssue.find_by_issue_id(issue.id)
return unless link
EpicIssues::DestroyService.new(link, current_user).execute
end
end
end
end
end
---
title: Update epic dates when creating an issue that adds the epic using commands
merge_request: 15062
author:
type: fixed
......@@ -2,7 +2,6 @@ require 'spec_helper'
describe Issues::CreateService do
let(:project) { create(:project) }
let(:opts) do
{
title: 'Awesome issue',
......@@ -30,6 +29,7 @@ describe Issues::CreateService do
let(:reporter) { create(:user) }
before do
stub_licensed_features(epics: true)
project.add_reporter(reporter)
end
......@@ -39,5 +39,38 @@ describe Issues::CreateService do
expect(issue).to be_persisted
expect(issue.weight).to eq(9)
end
context 'when epics are enabled' do
let(:group) { create(:group) }
let(:project1) { create(:project, group: group) }
let(:epic) { create(:epic, group: group, start_date_is_fixed: false, due_date_is_fixed: false) }
before do
stub_licensed_features(epics: true)
group.add_reporter(reporter)
project1.add_reporter(reporter)
end
context 'when using quick actions' do
context 'with epic and milestone in commands only' do
let(:milestone) { create(:milestone, group: group, start_date: Date.today, due_date: 7.days.from_now) }
let(:opts) do
{
title: 'Awesome issue',
description: %(/epic #{epic.to_reference}\n/milestone #{milestone.to_reference}")
}
end
it 'sets epic and milestone to issuable and update epic start and due date' do
issue = described_class.new(project1, reporter, opts).execute
expect(issue.milestone).to eq(milestone)
expect(issue.epic).to eq(epic)
expect(epic.reload.start_date).to eq(milestone.start_date)
expect(epic.due_date).to eq(milestone.due_date)
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