summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChantal Rollison <crollison@gitlab.com>2018-06-20 07:41:23 -0700
committerChantal Rollison <crollison@gitlab.com>2018-06-26 09:49:52 -0700
commit17437441ec978a50d094ec7f6ff31e2fa17cb683 (patch)
tree193fe392b8cad248e4547baa160f4296ece577ea
parent70bf08b5d34e71bb67d3a71a9f6aae553f0d9f4a (diff)
downloadgitlab-ce-ccr/maintain_labels.tar.gz
Keep label on issue when movingccr/maintain_labels
-rw-r--r--app/services/issues/move_service.rb3
-rw-r--r--changelogs/unreleased/cr-keep-issue-labels.yml5
-rw-r--r--spec/services/issues/move_service_spec.rb26
3 files changed, 30 insertions, 4 deletions
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index 78e79344c99..6e5c29a5c40 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -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)
diff --git a/changelogs/unreleased/cr-keep-issue-labels.yml b/changelogs/unreleased/cr-keep-issue-labels.yml
new file mode 100644
index 00000000000..051e7faffea
--- /dev/null
+++ b/changelogs/unreleased/cr-keep-issue-labels.yml
@@ -0,0 +1,5 @@
+---
+title: Keeps the label on an issue when the issue is moved.
+merge_request: 20036
+author:
+type: fixed
diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb
index a9aee9e100f..74d132d2857 100644
--- a/spec/services/issues/move_service_spec.rb
+++ b/spec/services/issues/move_service_spec.rb
@@ -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 'ancestor labels are set on new issue', :nested_groups do
+ it 'moves the associated label to the new project' 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)
+
+ reloaded_issue = new_issue.reload
+ expect(label_issue.labels).to include(label)
+ expect(reloaded_issue.project).to eq(new_project)
+ expect(reloaded_issue.labels).to include(label)
+ end
+ end
+
context 'generic issue' do
include_context 'issue move executed'