Skip to content
Snippets Groups Projects
Commit 49ec98d1 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Recreates the label priorities when moving project to another group

parent 301264be
No related branches found
No related tags found
1 merge request!6425Add group level labels
......@@ -14,7 +14,7 @@ def execute
return unless group.present?
Label.transaction do
labels_to_transfer = Label.where(id: label_links.select(:label_id).uniq)
labels_to_transfer = Label.where(id: label_links.select(:label_id))
labels_to_transfer.find_each do |label|
new_label_id = find_or_create_label!(label)
......@@ -22,6 +22,7 @@ def execute
next if new_label_id == label.id
LabelLink.where(label_id: label.id).update_all(label_id: new_label_id)
LabelPriority.where(project_id: project.id, label_id: label.id).update_all(label_id: new_label_id)
end
end
end
......
......@@ -26,6 +26,16 @@
expect { service.execute }.to change(project.labels, :count).by(2)
end
it 'recreates label priorities related to the missing group labels' do
create(:label_priority, project: project, label: group_label_1, priority: 1)
service.execute
new_project_label = project.labels.find_by(title: group_label_1.title)
expect(new_project_label.id).not_to eq group_label_1.id
expect(new_project_label.priorities).not_to be_empty
end
it 'does not recreate missing group labels that are not applied to issues or merge requests' do
service.execute
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment