Commit e5dd1ae7 authored by Sean McGivern's avatar Sean McGivern

Merge branch '199878-issue-promotion' into 'master'

Inherit parent epic during an issue promotion

See merge request gitlab-org/gitlab!37109
parents 4ce3e71e 46cbbbb3
......@@ -271,6 +271,7 @@ The following issue metadata will be copied to the epic:
- Upvotes/downvotes.
- Participants.
- Group labels that the issue already has.
- Parent epic. **(ULTIMATE)**
## Manage multi-level child epics **(ULTIMATE)**
......
......@@ -52,10 +52,15 @@ module Epics
def params
{
title: original_entity.title
title: original_entity.title,
parent: issue_epic
}
end
def issue_epic
original_entity.epic_issue&.epic
end
def add_note_from
SystemNoteService.issue_promoted(new_entity, original_entity, current_user, direction: :from)
end
......
---
title: Inherit parent epic during an issue promotion
merge_request: 37109
author:
type: changed
......@@ -8,6 +8,8 @@ RSpec.describe 'Issue promotion', :js do
let(:group) { create(:group) }
let(:project) { create(:project, :public, group: group) }
let(:issue) { create(:issue, project: project) }
let(:parent_epic) { create(:epic, group: group) }
let!(:epic_issue) { create(:epic_issue, issue: issue, epic: parent_epic) }
let(:user) { create(:user) }
before do
......@@ -21,7 +23,7 @@ RSpec.describe 'Issue promotion', :js do
expect(page).not_to have_content 'Promoted issue to an epic.'
expect(issue.reload).to be_open
expect(Epic.count).to be_zero
expect(Epic.count).to eq(1)
end
end
......@@ -39,7 +41,7 @@ RSpec.describe 'Issue promotion', :js do
expect(page).not_to have_content 'Promoted issue to an epic.'
expect(issue.reload).to be_open
expect(Epic.count).to be_zero
expect(Epic.count).to eq(1)
end
end
......@@ -70,6 +72,7 @@ RSpec.describe 'Issue promotion', :js do
expect(epic.title).to eq(issue.title)
expect(epic.description).to eq(issue.description)
expect(epic.author).to eq(user)
expect(epic.parent).to eq(parent_epic)
end
# Spec for https://gitlab.com/gitlab-org/gitlab/-/issues/215549
......
......@@ -69,6 +69,7 @@ RSpec.describe Epics::IssuePromoteService do
expect(epic.description).to eq(issue.description)
expect(epic.author).to eq(user)
expect(epic.group).to eq(group)
expect(epic.parent).to be_nil
end
it 'copies group labels assigned to the issue' do
......@@ -104,6 +105,21 @@ RSpec.describe Epics::IssuePromoteService do
end
end
context 'when an issue belongs to an epic' do
let(:parent_epic) { create(:epic, group: group) }
let!(:epic_issue) { create(:epic_issue, epic: parent_epic, issue: issue) }
it 'creates a new epic with correct attributes' do
subject.execute(issue)
expect(epic.title).to eq(issue.title)
expect(epic.description).to eq(issue.description)
expect(epic.author).to eq(user)
expect(epic.group).to eq(group)
expect(epic.parent).to eq(parent_epic)
end
end
context 'when issue was already promoted' do
it 'raises error' do
epic = create(:epic, group: group)
......
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