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