Commit 17a09f96 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '196806-bulk-edit-iterations' into 'master'

Enable editing iterations in BulkUpdateService

See merge request gitlab-org/gitlab!50113
parents 111531e1 ce8e3914
......@@ -217,6 +217,7 @@ module IssuableActions
:issuable_ids,
:assignee_id,
:milestone_id,
:sprint_id,
:state_event,
:subscription_event,
assignee_ids: [],
......
......@@ -34,6 +34,8 @@ module Issuable
def permitted_attrs(type)
attrs = %i(state_event milestone_id add_label_ids remove_label_ids subscription_event)
attrs.push(:sprint_id) if type == 'issue'
if type == 'issue' || type == 'merge_request'
attrs.push(:assignee_ids)
else
......
......@@ -3,8 +3,8 @@
require 'spec_helper'
RSpec.describe Issuable::BulkUpdateService do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, namespace: user.namespace) }
def bulk_update(issuables, extra_params = {})
bulk_update_params = extra_params
......@@ -31,6 +31,23 @@ RSpec.describe Issuable::BulkUpdateService do
end
end
shared_examples 'updates iterations' do
it 'succeeds' do
result = bulk_update(issuables, sprint_id: iteration.id)
expect(result.success?).to be_truthy
expect(result.payload[:count]).to eq(issuables.count)
end
it 'updates the issuables iteration' do
bulk_update(issuables, sprint_id: iteration.id)
issuables.each do |issuable|
expect(issuable.reload.iteration).to eq(iteration)
end
end
end
shared_examples 'updating labels' do
def create_issue_with_labels(labels)
create(:labeled_issue, project: project, labels: labels)
......@@ -233,6 +250,21 @@ RSpec.describe Issuable::BulkUpdateService do
it_behaves_like 'updates milestones'
end
describe 'updating iterations' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:issuables) { [create(:issue, project: project)] }
let_it_be(:iteration) { create(:iteration, group: group) }
let(:parent) { project }
before do
group.add_reporter(user)
end
it_behaves_like 'updates iterations'
end
describe 'updating labels' do
let(:bug) { create(:label, project: project) }
let(:regression) { create(:label, project: project) }
......@@ -283,7 +315,7 @@ RSpec.describe Issuable::BulkUpdateService do
end
context 'with issuables at a group level' do
let(:group) { create(:group) }
let_it_be(:group) { create(:group) }
let(:parent) { group }
before do
......@@ -315,6 +347,19 @@ RSpec.describe Issuable::BulkUpdateService do
end
end
describe 'updating iterations' do
let_it_be(:iteration) { create(:iteration, group: group) }
let_it_be(:project) { create(:project, :repository, group: group) }
context 'when issues' do
let_it_be(:issue1) { create(:issue, project: project) }
let_it_be(:issue2) { create(:issue, project: project) }
let_it_be(:issuables) { [issue1, issue2] }
it_behaves_like 'updates iterations'
end
end
describe 'updating labels' do
let(:project) { create(:project, :repository, group: group) }
let(:bug) { create(:group_label, 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