Commit dc53ff7b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix Epic bulk updates leaking to other epics

When doing a bulk update on epics, the set of labels for the first
selected epic are copied over to the rest of the epics.

This is because we compute the final list of labels and sets it to
`params` and this `params` is the same one used for updating other
epics.

Changelog: fixed
EE: true
parent 31462b14
......@@ -57,7 +57,11 @@ module Issuable
items.each do |issuable|
next unless can?(current_user, :"update_#{type}", issuable)
update_class.new(**update_class.constructor_container_arg(issuable.issuing_parent), current_user: current_user, params: params).execute(issuable)
update_class.new(
**update_class.constructor_container_arg(issuable.issuing_parent),
current_user: current_user,
params: params.dup
).execute(issuable)
end
items
......
......@@ -203,6 +203,19 @@ RSpec.describe Issuable::BulkUpdateService do
let(:new_value) { [label2, label3] }
it_behaves_like 'updates issuables attribute', :labels
context 'when epics have different labels' do
let(:label4) { create(:group_label, group: group, title: 'feature') }
let(:epic1) { create(:epic, group: group, labels: [label1, label4]) }
it 'keeps existing labels' do
expect(subject.success?).to be_truthy
expect(subject.payload[:count]).to eq(issuables.count)
expect(epic1.reload.labels).to contain_exactly(label4, label2, label3)
expect(epic2.reload.labels).to contain_exactly(label2, label3)
end
end
end
context 'when epics are disabled' do
......
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