Commit e46676a6 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ccr/maintain_labels' into 'master'

Keep label on issue when moving

Closes #46098

See merge request gitlab-org/gitlab-ce!20036
parents d810e65a 6a3f9cef
......@@ -58,7 +58,8 @@ module Issues
def cloneable_label_ids
params = {
project_id: @new_project.id,
title: @old_issue.labels.pluck(:title)
title: @old_issue.labels.pluck(:title),
include_ancestor_groups: true
}
LabelsFinder.new(current_user, params).execute.pluck(:id)
......
---
title: Keeps the label on an issue when the issue is moved.
merge_request: 20036
author:
type: fixed
......@@ -5,8 +5,11 @@ describe Issues::MoveService do
let(:author) { create(:user) }
let(:title) { 'Some issue' }
let(:description) { 'Some issue description' }
let(:old_project) { create(:project) }
let(:new_project) { create(:project) }
let(:group) { create(:group, :private) }
let(:sub_group_1) { create(:group, :private, parent: group) }
let(:sub_group_2) { create(:group, :private, parent: group) }
let(:old_project) { create(:project, namespace: sub_group_1) }
let(:new_project) { create(:project, namespace: sub_group_2) }
let(:milestone1) { create(:milestone, project_id: old_project.id, title: 'v9.0') }
let(:old_issue) do
......@@ -14,7 +17,7 @@ describe Issues::MoveService do
project: old_project, author: author, milestone: milestone1)
end
let(:move_service) do
subject(:move_service) do
described_class.new(old_project, user)
end
......@@ -102,6 +105,23 @@ describe Issues::MoveService do
end
end
context 'issue with group labels', :nested_groups do
it 'assigns group labels to new issue' do
label = create(:group_label, group: group)
label_issue = create(:labeled_issue, description: description, project: old_project,
milestone: milestone1, labels: [label])
old_project.add_reporter(user)
new_project.add_reporter(user)
new_issue = move_service.execute(label_issue, new_project)
expect(new_issue).to have_attributes(
project: new_project,
labels: include(label)
)
end
end
context 'generic issue' do
include_context 'issue move executed'
......
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