2019-04-11 08:17:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-05-15 09:59:15 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe Issuable::BulkUpdateService do
|
2020-12-17 13:10:14 -05:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, :repository, namespace: user.namespace) }
|
2013-05-16 06:32:16 -04:00
|
|
|
|
2017-05-04 08:11:15 -04:00
|
|
|
def bulk_update(issuables, extra_params = {})
|
2016-07-20 18:45:19 -04:00
|
|
|
bulk_update_params = extra_params
|
2017-05-04 08:11:15 -04:00
|
|
|
.reverse_merge(issuable_ids: Array(issuables).map(&:id).join(','))
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2017-05-04 08:11:15 -04:00
|
|
|
type = Array(issuables).first.model_name.param_key
|
2019-12-02 04:06:58 -05:00
|
|
|
Issuable::BulkUpdateService.new(parent, user, bulk_update_params).execute(type)
|
2016-07-20 18:45:19 -04:00
|
|
|
end
|
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
shared_examples 'updates milestones' do
|
|
|
|
it 'succeeds' do
|
2019-07-23 10:39:18 -04:00
|
|
|
result = bulk_update(issuables, milestone_id: milestone.id)
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(issuables.count)
|
2015-06-22 16:00:54 -04:00
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2019-07-23 10:39:18 -04:00
|
|
|
it 'updates the issuables milestone' do
|
|
|
|
bulk_update(issuables, milestone_id: milestone.id)
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2019-07-23 10:39:18 -04:00
|
|
|
issuables.each do |issuable|
|
|
|
|
expect(issuable.reload.milestone).to eq(milestone)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
Tidy up BulkUpdateService specs
1. Don't use instance variables, use `let` instead.
2. Add descriptions for all specs.
3. Share variables where possible.
4. Give labels more vivid names than 1, 2, and 3.
5. Remove deprecation warnings by passing issue IDs as '1,2,3' instead
of an array, as that's how they're passed by the front-end. (The
deprecation warning is for passing a nested array, which is what
happens if an actual array is passed, as:
`[1, 2, 3].split(',') == [[1, 2, 3]]`
2016-05-02 12:36:25 -04:00
|
|
|
end
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
2018-12-07 10:48:38 -05:00
|
|
|
|
2019-08-08 02:25:20 -04:00
|
|
|
shared_examples 'updating labels' do
|
|
|
|
def create_issue_with_labels(labels)
|
|
|
|
create(:labeled_issue, project: project, labels: labels)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:issue_all_labels) { create_issue_with_labels([bug, regression, merge_requests]) }
|
|
|
|
let(:issue_bug_and_regression) { create_issue_with_labels([bug, regression]) }
|
|
|
|
let(:issue_bug_and_merge_requests) { create_issue_with_labels([bug, merge_requests]) }
|
|
|
|
let(:issue_no_labels) { create(:issue, project: project) }
|
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_regression, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
|
|
|
|
let(:add_labels) { [] }
|
|
|
|
let(:remove_labels) { [] }
|
|
|
|
|
|
|
|
let(:bulk_update_params) do
|
|
|
|
{
|
|
|
|
add_label_ids: add_labels.map(&:id),
|
|
|
|
remove_label_ids: remove_labels.map(&:id)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
bulk_update(issues, bulk_update_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when add_label_ids are passed' do
|
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:add_labels) { [bug, regression, merge_requests] }
|
|
|
|
|
|
|
|
it 'adds those label IDs to all issues passed' do
|
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(include(*add_labels.map(&:id)))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when remove_label_ids are passed' do
|
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:remove_labels) { [bug, regression, merge_requests] }
|
|
|
|
|
|
|
|
it 'removes those label IDs from all issues passed' do
|
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(be_empty)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when add_label_ids and remove_label_ids are passed' do
|
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:add_labels) { [bug] }
|
|
|
|
let(:remove_labels) { [merge_requests] }
|
|
|
|
|
|
|
|
it 'adds the label IDs to all issues passed' do
|
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes the label IDs from all issues passed' do
|
|
|
|
expect(issues.map(&:reload).flat_map(&:label_ids)).not_to include(merge_requests.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
|
|
|
end
|
|
|
|
end
|
2020-06-05 11:08:23 -04:00
|
|
|
end
|
2019-08-08 02:25:20 -04:00
|
|
|
|
2021-04-30 08:12:30 -04:00
|
|
|
shared_examples 'scheduling cached group count clear' do
|
|
|
|
it 'schedules worker' do
|
|
|
|
expect(Issuables::ClearGroupsIssueCounterWorker).to receive(:perform_async)
|
|
|
|
|
|
|
|
bulk_update(issuables, params)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'not scheduling cached group count clear' do
|
|
|
|
it 'does not schedule worker' do
|
|
|
|
expect(Issuables::ClearGroupsIssueCounterWorker).not_to receive(:perform_async)
|
|
|
|
|
|
|
|
bulk_update(issuables, params)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-05 11:08:23 -04:00
|
|
|
context 'with issuables at a project level' do
|
|
|
|
let(:parent) { project }
|
2019-08-08 02:25:20 -04:00
|
|
|
|
2020-06-05 11:08:23 -04:00
|
|
|
context 'with unpermitted attributes' do
|
|
|
|
let(:issues) { create_list(:issue, 2, project: project) }
|
|
|
|
let(:label) { create(:label, project: project) }
|
2019-08-08 02:25:20 -04:00
|
|
|
|
2020-06-05 11:08:23 -04:00
|
|
|
it 'does not update the issues' do
|
|
|
|
bulk_update(issues, label_ids: [label.id])
|
2019-08-08 02:25:20 -04:00
|
|
|
|
2020-06-05 11:08:23 -04:00
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).not_to include(label.id)
|
2019-08-08 02:25:20 -04:00
|
|
|
end
|
|
|
|
end
|
2019-12-02 04:06:58 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'close issues' do
|
|
|
|
let(:issues) { create_list(:issue, 2, project: project) }
|
2018-12-07 10:48:38 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'succeeds and returns the correct number of issues updated' do
|
|
|
|
result = bulk_update(issues, state_event: 'close')
|
2018-12-07 10:48:38 -05:00
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(issues.count)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
2018-12-07 10:48:38 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'closes all the issues passed' do
|
|
|
|
bulk_update(issues, state_event: 'close')
|
|
|
|
|
|
|
|
expect(project.issues.opened).to be_empty
|
|
|
|
expect(project.issues.closed).not_to be_empty
|
2018-12-07 10:48:38 -05:00
|
|
|
end
|
2021-04-30 08:12:30 -04:00
|
|
|
|
|
|
|
it_behaves_like 'scheduling cached group count clear' do
|
|
|
|
let(:issuables) { issues }
|
|
|
|
let(:params) { { state_event: 'close' } }
|
|
|
|
end
|
2018-12-07 10:48:38 -05:00
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'reopen issues' do
|
|
|
|
let(:issues) { create_list(:closed_issue, 2, project: project) }
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'succeeds and returns the correct number of issues updated' do
|
|
|
|
result = bulk_update(issues, state_event: 'reopen')
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(issues.count)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'reopens all the issues passed' do
|
|
|
|
bulk_update(issues, state_event: 'reopen')
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
expect(project.issues.closed).to be_empty
|
|
|
|
expect(project.issues.opened).not_to be_empty
|
|
|
|
end
|
2021-04-30 08:12:30 -04:00
|
|
|
|
|
|
|
it_behaves_like 'scheduling cached group count clear' do
|
|
|
|
let(:issuables) { issues }
|
|
|
|
let(:params) { { state_event: 'reopen' } }
|
|
|
|
end
|
Tidy up BulkUpdateService specs
1. Don't use instance variables, use `let` instead.
2. Add descriptions for all specs.
3. Share variables where possible.
4. Give labels more vivid names than 1, 2, and 3.
5. Remove deprecation warnings by passing issue IDs as '1,2,3' instead
of an array, as that's how they're passed by the front-end. (The
deprecation warning is for passing a nested array, which is what
happens if an actual array is passed, as:
`[1, 2, 3].split(',') == [[1, 2, 3]]`
2016-05-02 12:36:25 -04:00
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'updating merge request assignee' do
|
|
|
|
let(:merge_request) { create(:merge_request, target_project: project, source_project: project, assignees: [user]) }
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
context 'when the new assignee ID is a valid user' do
|
|
|
|
it 'succeeds' do
|
|
|
|
new_assignee = create(:user)
|
|
|
|
project.add_developer(new_assignee)
|
2016-12-14 16:39:53 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
result = bulk_update(merge_request, assignee_ids: [user.id, new_assignee.id])
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(1)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'updates the assignee to the user ID passed' do
|
|
|
|
assignee = create(:user)
|
|
|
|
project.add_developer(assignee)
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
expect { bulk_update(merge_request, assignee_ids: [assignee.id]) }
|
|
|
|
.to change { merge_request.reload.assignee_ids }.from([user.id]).to([assignee.id])
|
|
|
|
end
|
Tidy up BulkUpdateService specs
1. Don't use instance variables, use `let` instead.
2. Add descriptions for all specs.
3. Share variables where possible.
4. Give labels more vivid names than 1, 2, and 3.
5. Remove deprecation warnings by passing issue IDs as '1,2,3' instead
of an array, as that's how they're passed by the front-end. (The
deprecation warning is for passing a nested array, which is what
happens if an actual array is passed, as:
`[1, 2, 3].split(',') == [[1, 2, 3]]`
2016-05-02 12:36:25 -04:00
|
|
|
end
|
2015-02-25 04:29:33 -05:00
|
|
|
|
2020-03-30 17:08:01 -04:00
|
|
|
context "when the new assignee ID is #{IssuableFinder::Params::NONE}" do
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'unassigns the issues' do
|
2020-03-30 17:08:01 -04:00
|
|
|
expect { bulk_update(merge_request, assignee_ids: [IssuableFinder::Params::NONE]) }
|
2019-07-09 07:46:16 -04:00
|
|
|
.to change { merge_request.reload.assignee_ids }.to([])
|
|
|
|
end
|
Tidy up BulkUpdateService specs
1. Don't use instance variables, use `let` instead.
2. Add descriptions for all specs.
3. Share variables where possible.
4. Give labels more vivid names than 1, 2, and 3.
5. Remove deprecation warnings by passing issue IDs as '1,2,3' instead
of an array, as that's how they're passed by the front-end. (The
deprecation warning is for passing a nested array, which is what
happens if an actual array is passed, as:
`[1, 2, 3].split(',') == [[1, 2, 3]]`
2016-05-02 12:36:25 -04:00
|
|
|
end
|
2015-02-25 04:29:33 -05:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
context 'when the new assignee ID is not present' do
|
|
|
|
it 'does not unassign' do
|
|
|
|
expect { bulk_update(merge_request, assignee_ids: []) }
|
|
|
|
.not_to change { merge_request.reload.assignee_ids }
|
|
|
|
end
|
2017-05-04 08:11:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'updating issue assignee' do
|
|
|
|
let(:issue) { create(:issue, project: project, assignees: [user]) }
|
2017-05-04 08:11:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
context 'when the new assignee ID is a valid user' do
|
|
|
|
it 'succeeds' do
|
|
|
|
new_assignee = create(:user)
|
|
|
|
project.add_developer(new_assignee)
|
2017-05-04 08:11:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
result = bulk_update(issue, assignee_ids: [new_assignee.id])
|
2017-05-04 08:11:15 -04:00
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(1)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
2017-05-04 08:11:15 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'updates the assignee to the user ID passed' do
|
|
|
|
assignee = create(:user)
|
|
|
|
project.add_developer(assignee)
|
|
|
|
expect { bulk_update(issue, assignee_ids: [assignee.id]) }
|
|
|
|
.to change { issue.reload.assignees.first }.from(user).to(assignee)
|
|
|
|
end
|
2017-05-04 08:11:15 -04:00
|
|
|
end
|
|
|
|
|
2020-03-30 17:08:01 -04:00
|
|
|
context "when the new assignee ID is #{IssuableFinder::Params::NONE}" do
|
2019-07-09 07:46:16 -04:00
|
|
|
it "unassigns the issues" do
|
2020-03-30 17:08:01 -04:00
|
|
|
expect { bulk_update(issue, assignee_ids: [IssuableFinder::Params::NONE.to_s]) }
|
2019-07-09 07:46:16 -04:00
|
|
|
.to change { issue.reload.assignees.count }.from(1).to(0)
|
|
|
|
end
|
2017-05-04 08:11:15 -04:00
|
|
|
end
|
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
context 'when the new assignee ID is not present' do
|
|
|
|
it 'does not unassign' do
|
|
|
|
expect { bulk_update(issue, assignee_ids: []) }
|
2019-07-08 20:41:22 -04:00
|
|
|
.not_to change(issue.assignees, :count)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
Tidy up BulkUpdateService specs
1. Don't use instance variables, use `let` instead.
2. Add descriptions for all specs.
3. Share variables where possible.
4. Give labels more vivid names than 1, 2, and 3.
5. Remove deprecation warnings by passing issue IDs as '1,2,3' instead
of an array, as that's how they're passed by the front-end. (The
deprecation warning is for passing a nested array, which is what
happens if an actual array is passed, as:
`[1, 2, 3].split(',') == [[1, 2, 3]]`
2016-05-02 12:36:25 -04:00
|
|
|
end
|
2015-02-25 04:29:33 -05:00
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'updating milestones' do
|
2019-07-23 10:39:18 -04:00
|
|
|
let(:issuables) { [create(:issue, project: project)] }
|
2019-07-09 07:46:16 -04:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it_behaves_like 'updates milestones'
|
2021-04-30 08:12:30 -04:00
|
|
|
|
|
|
|
it_behaves_like 'not scheduling cached group count clear' do
|
|
|
|
let(:params) { { milestone_id: milestone.id } }
|
|
|
|
end
|
Tidy up BulkUpdateService specs
1. Don't use instance variables, use `let` instead.
2. Add descriptions for all specs.
3. Share variables where possible.
4. Give labels more vivid names than 1, 2, and 3.
5. Remove deprecation warnings by passing issue IDs as '1,2,3' instead
of an array, as that's how they're passed by the front-end. (The
deprecation warning is for passing a nested array, which is what
happens if an actual array is passed, as:
`[1, 2, 3].split(',') == [[1, 2, 3]]`
2016-05-02 12:36:25 -04:00
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'updating labels' do
|
|
|
|
let(:bug) { create(:label, project: project) }
|
|
|
|
let(:regression) { create(:label, project: project) }
|
|
|
|
let(:merge_requests) { create(:label, project: project) }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
2019-08-08 02:25:20 -04:00
|
|
|
it_behaves_like 'updating labels'
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'subscribe to issues' do
|
|
|
|
let(:issues) { create_list(:issue, 2, project: project) }
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
it 'subscribes the given user' do
|
|
|
|
bulk_update(issues, subscription_event: 'subscribe')
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
expect(issues).to all(be_subscribed(user, project))
|
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
|
|
|
|
2019-07-09 07:46:16 -04:00
|
|
|
describe 'unsubscribe from issues' do
|
|
|
|
let(:issues) do
|
|
|
|
create_list(:closed_issue, 2, project: project) do |issue|
|
2020-09-21 08:09:34 -04:00
|
|
|
issue.subscriptions.create!(user: user, project: project, subscribed: true)
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'unsubscribes the given user' do
|
|
|
|
bulk_update(issues, subscription_event: 'unsubscribe')
|
|
|
|
|
|
|
|
issues.each do |issue|
|
|
|
|
expect(issue).not_to be_subscribed(user, project)
|
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
|
|
|
end
|
2019-12-02 04:06:58 -05:00
|
|
|
|
|
|
|
describe 'updating issues from external project' do
|
|
|
|
it 'updates only issues that belong to the parent project' do
|
|
|
|
issue1 = create(:issue, project: project)
|
|
|
|
issue2 = create(:issue, project: create(:project))
|
|
|
|
result = bulk_update([issue1, issue2], assignee_ids: [user.id])
|
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(1)
|
2019-12-02 04:06:58 -05:00
|
|
|
|
|
|
|
expect(issue1.reload.assignees).to eq([user])
|
|
|
|
expect(issue2.reload.assignees).to be_empty
|
|
|
|
end
|
|
|
|
end
|
2019-07-09 07:46:16 -04:00
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2019-08-08 02:25:20 -04:00
|
|
|
context 'with issuables at a group level' do
|
2020-12-17 13:10:14 -05:00
|
|
|
let_it_be(:group) { create(:group) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2019-12-02 04:06:58 -05:00
|
|
|
let(:parent) { group }
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_reporter(user)
|
|
|
|
end
|
2016-07-20 18:45:19 -04:00
|
|
|
|
2019-07-23 10:39:18 -04:00
|
|
|
describe 'updating milestones' do
|
2019-07-09 07:46:16 -04:00
|
|
|
let(:milestone) { create(:milestone, group: group) }
|
2019-07-23 10:39:18 -04:00
|
|
|
let(:project) { create(:project, :repository, group: group) }
|
2019-07-09 07:46:16 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_maintainer(user)
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
2019-07-09 07:46:16 -04:00
|
|
|
|
2019-07-23 10:39:18 -04:00
|
|
|
context 'when issues' do
|
|
|
|
let(:issue1) { create(:issue, project: project) }
|
|
|
|
let(:issue2) { create(:issue, project: project) }
|
|
|
|
let(:issuables) { [issue1, issue2] }
|
|
|
|
|
|
|
|
it_behaves_like 'updates milestones'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when merge requests' do
|
|
|
|
let(:merge_request1) { create(:merge_request, source_project: project, source_branch: 'branch-1') }
|
|
|
|
let(:merge_request2) { create(:merge_request, source_project: project, source_branch: 'branch-2') }
|
|
|
|
let(:issuables) { [merge_request1, merge_request2] }
|
|
|
|
|
|
|
|
it_behaves_like 'updates milestones'
|
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
2019-08-08 02:25:20 -04:00
|
|
|
|
|
|
|
describe 'updating labels' do
|
|
|
|
let(:project) { create(:project, :repository, group: group) }
|
|
|
|
let(:bug) { create(:group_label, group: group) }
|
|
|
|
let(:regression) { create(:group_label, group: group) }
|
|
|
|
let(:merge_requests) { create(:group_label, group: group) }
|
|
|
|
|
|
|
|
it_behaves_like 'updating labels'
|
|
|
|
end
|
2019-12-02 04:06:58 -05:00
|
|
|
|
|
|
|
describe 'with issues from external group' do
|
|
|
|
it 'updates issues that belong to the parent group or descendants' do
|
|
|
|
issue1 = create(:issue, project: create(:project, group: group))
|
|
|
|
issue2 = create(:issue, project: create(:project, group: create(:group)))
|
|
|
|
issue3 = create(:issue, project: create(:project, group: create(:group, parent: group)))
|
|
|
|
milestone = create(:milestone, group: group)
|
|
|
|
result = bulk_update([issue1, issue2, issue3], milestone_id: milestone.id)
|
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
expect(result.success?).to be_truthy
|
|
|
|
expect(result.payload[:count]).to eq(2)
|
2019-12-02 04:06:58 -05:00
|
|
|
|
|
|
|
expect(issue1.reload.milestone).to eq(milestone)
|
|
|
|
expect(issue2.reload.milestone).to be_nil
|
|
|
|
expect(issue3.reload.milestone).to eq(milestone)
|
|
|
|
end
|
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
end
|