2013-05-15 09:59:15 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-09-06 08:49:49 -04:00
|
|
|
describe Issuable::BulkUpdateService, services: true do
|
2016-07-20 18:45:19 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:empty_project, namespace: user.namespace) }
|
2013-05-16 06:32:16 -04:00
|
|
|
|
2016-07-20 18:45:19 -04:00
|
|
|
def bulk_update(issues, extra_params = {})
|
|
|
|
bulk_update_params = extra_params
|
2016-09-06 08:49:49 -04:00
|
|
|
.reverse_merge(issuable_ids: Array(issues).map(&:id).join(','))
|
2013-05-15 09:59:15 -04:00
|
|
|
|
2016-09-06 08:49:49 -04:00
|
|
|
Issuable::BulkUpdateService.new(project, user, bulk_update_params).execute('issue')
|
2016-07-20 18:45:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'close issues' do
|
|
|
|
let(:issues) { create_list(:issue, 2, project: project) }
|
2013-05-15 09:59:15 -04:00
|
|
|
|
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
|
|
|
it 'succeeds and returns the correct number of issues updated' do
|
2016-07-20 18:45:19 -04:00
|
|
|
result = bulk_update(issues, state_event: 'close')
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(result[:success]).to be_truthy
|
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
|
|
|
expect(result[:count]).to eq(issues.count)
|
2015-06-22 16:00:54 -04:00
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
|
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
|
|
|
it 'closes all the issues passed' do
|
2016-07-20 18:45:19 -04:00
|
|
|
bulk_update(issues, state_event: 'close')
|
|
|
|
|
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
|
|
|
expect(project.issues.opened).to be_empty
|
|
|
|
expect(project.issues.closed).not_to be_empty
|
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
end
|
|
|
|
|
2016-07-20 18:45:19 -04:00
|
|
|
describe 'reopen issues' do
|
|
|
|
let(:issues) { create_list(:closed_issue, 2, project: project) }
|
2013-05-15 09:59:15 -04:00
|
|
|
|
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
|
|
|
it 'succeeds and returns the correct number of issues updated' do
|
2016-07-20 18:45:19 -04:00
|
|
|
result = bulk_update(issues, state_event: 'reopen')
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(result[:success]).to be_truthy
|
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
|
|
|
expect(result[:count]).to eq(issues.count)
|
2015-06-22 16:00:54 -04:00
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
|
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
|
|
|
it 'reopens all the issues passed' do
|
2016-07-20 18:45:19 -04:00
|
|
|
bulk_update(issues, state_event: 'reopen')
|
|
|
|
|
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
|
|
|
expect(project.issues.closed).to be_empty
|
|
|
|
expect(project.issues.opened).not_to be_empty
|
|
|
|
end
|
2013-05-16 06:32: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
|
|
|
describe 'updating assignee' do
|
2016-07-20 18:45:19 -04:00
|
|
|
let(:issue) { create(:issue, project: project, assignee: user) }
|
2013-05-15 09:59:15 -04:00
|
|
|
|
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
|
|
|
context 'when the new assignee ID is a valid user' do
|
|
|
|
it 'succeeds' do
|
2016-12-14 16:39:53 -05:00
|
|
|
new_assignee = create(:user)
|
|
|
|
project.team << [new_assignee, :developer]
|
|
|
|
|
|
|
|
result = bulk_update(issue, assignee_id: new_assignee.id)
|
2016-07-20 18:45:19 -04:00
|
|
|
|
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
|
|
|
expect(result[:success]).to be_truthy
|
|
|
|
expect(result[:count]).to eq(1)
|
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
|
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
|
|
|
it 'updates the assignee to the use ID passed' do
|
2016-07-20 18:45:19 -04:00
|
|
|
assignee = create(:user)
|
2016-12-14 16:39:53 -05:00
|
|
|
project.team << [assignee, :developer]
|
2016-07-20 18:45:19 -04:00
|
|
|
|
|
|
|
expect { bulk_update(issue, assignee_id: assignee.id) }
|
|
|
|
.to change { issue.reload.assignee }.from(user).to(assignee)
|
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
|
|
|
|
end
|
2015-02-25 04:29:33 -05:00
|
|
|
|
2016-12-14 16:39:53 -05:00
|
|
|
context "when the new assignee ID is #{IssuableFinder::NONE}" do
|
|
|
|
it "unassigns the issues" do
|
|
|
|
expect { bulk_update(issue, assignee_id: IssuableFinder::NONE) }
|
2016-07-20 18:45:19 -04:00
|
|
|
.to change { issue.reload.assignee }.to(nil)
|
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
|
|
|
|
|
2016-05-23 13:02:53 -04:00
|
|
|
context 'when the new assignee ID is not present' do
|
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
|
|
|
it 'does not unassign' do
|
2016-07-20 18:45:19 -04:00
|
|
|
expect { bulk_update(issue, assignee_id: nil) }
|
|
|
|
.not_to change { issue.reload.assignee }
|
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-15 09:59:15 -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
|
|
|
describe 'updating milestones' do
|
2016-07-20 18:45:19 -04:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
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
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
2013-05-16 06:32:16 -04:00
|
|
|
|
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
|
|
|
it 'succeeds' do
|
2016-07-20 18:45:19 -04:00
|
|
|
result = bulk_update(issue, milestone_id: milestone.id)
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(result[:success]).to be_truthy
|
|
|
|
expect(result[:count]).to eq(1)
|
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
|
|
|
|
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
|
|
|
it 'updates the issue milestone' do
|
2016-07-20 18:45:19 -04:00
|
|
|
expect { bulk_update(issue, milestone_id: milestone.id) }
|
|
|
|
.to change { issue.reload.milestone }.from(nil).to(milestone)
|
2015-06-22 16:00:54 -04:00
|
|
|
end
|
2013-05-15 09:59:15 -04:00
|
|
|
end
|
|
|
|
|
2016-05-02 11:25:21 -04:00
|
|
|
describe 'updating labels' do
|
|
|
|
def create_issue_with_labels(labels)
|
2016-07-20 18:45:19 -04:00
|
|
|
create(:labeled_issue, project: project, labels: labels)
|
2016-05-02 11:25:21 -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
|
|
|
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
|
|
|
|
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
|
|
|
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]) }
|
2016-05-02 11:25:21 -04:00
|
|
|
let(:issue_no_labels) { create(:issue, project: project) }
|
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
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_regression, issue_bug_and_merge_requests, issue_no_labels] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
let(:labels) { [] }
|
|
|
|
let(:add_labels) { [] }
|
|
|
|
let(:remove_labels) { [] }
|
|
|
|
|
2016-07-20 18:45:19 -04:00
|
|
|
let(:bulk_update_params) do
|
2016-05-02 11:25:21 -04:00
|
|
|
{
|
2016-07-20 18:45:19 -04:00
|
|
|
label_ids: labels.map(&:id),
|
|
|
|
add_label_ids: add_labels.map(&:id),
|
2016-05-02 11:25:21 -04:00
|
|
|
remove_label_ids: remove_labels.map(&:id),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2016-07-20 18:45:19 -04:00
|
|
|
before do
|
|
|
|
bulk_update(issues, bulk_update_params)
|
|
|
|
end
|
|
|
|
|
2016-05-02 11:25:21 -04:00
|
|
|
context 'when label_ids are passed' do
|
|
|
|
let(:issues) { [issue_all_labels, issue_no_labels] }
|
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
|
|
|
let(:labels) { [bug, regression] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
it 'updates the labels of all issues passed to the labels passed' do
|
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(eq(labels.map(&:id)))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
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
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
2016-05-31 06:14:15 -04:00
|
|
|
|
|
|
|
context 'when those label IDs are empty' do
|
|
|
|
let(:labels) { [] }
|
|
|
|
|
|
|
|
it 'updates the issues passed to have no labels' do
|
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(be_empty)
|
|
|
|
end
|
|
|
|
end
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when add_label_ids are passed' do
|
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
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:add_labels) { [bug, regression, merge_requests] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
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
|
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
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when remove_label_ids are passed' do
|
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
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:remove_labels) { [bug, regression, merge_requests] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
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
|
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
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when add_label_ids and remove_label_ids are passed' do
|
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
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:add_labels) { [bug] }
|
|
|
|
let(:remove_labels) { [merge_requests] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
it 'adds the label IDs to all issues passed' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes the label IDs from all issues passed' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(merge_requests.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
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
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when add_label_ids and label_ids are passed' do
|
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
|
|
|
let(:issues) { [issue_all_labels, issue_bug_and_regression, issue_bug_and_merge_requests] }
|
|
|
|
let(:labels) { [merge_requests] }
|
|
|
|
let(:add_labels) { [regression] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
it 'adds the label IDs to all issues passed' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(include(regression.id))
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'ignores the label IDs parameter' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
|
|
|
expect(issue_no_labels.label_ids).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when remove_label_ids and label_ids are passed' do
|
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
|
|
|
let(:issues) { [issue_no_labels, issue_bug_and_regression] }
|
|
|
|
let(:labels) { [merge_requests] }
|
|
|
|
let(:remove_labels) { [regression] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'removes the label IDs from all issues passed' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'ignores the label IDs parameter' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(merge_requests.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
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
|
|
|
expect(issue_all_labels.label_ids).to contain_exactly(bug.id, regression.id, merge_requests.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when add_label_ids, remove_label_ids, and label_ids are passed' do
|
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
|
|
|
let(:issues) { [issue_bug_and_merge_requests, issue_no_labels] }
|
|
|
|
let(:labels) { [regression] }
|
|
|
|
let(:add_labels) { [bug] }
|
|
|
|
let(:remove_labels) { [merge_requests] }
|
2016-05-02 11:25:21 -04:00
|
|
|
|
|
|
|
it 'adds the label IDs to all issues passed' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes the label IDs from all issues passed' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(merge_requests.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'ignores the label IDs parameter' do
|
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
|
|
|
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not update issues not passed in' do
|
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
|
|
|
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
|
2016-05-02 11:25:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2016-07-20 18:45:19 -04:00
|
|
|
describe 'subscribe to issues' do
|
|
|
|
let(:issues) { create_list(:issue, 2, project: project) }
|
2016-07-12 19:18:13 -04:00
|
|
|
|
|
|
|
it 'subscribes the given user' do
|
2016-07-20 18:45:19 -04:00
|
|
|
bulk_update(issues, subscription_event: 'subscribe')
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2016-11-04 14:19:08 -04:00
|
|
|
expect(issues).to all(be_subscribed(user, project))
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
2016-07-20 18:45:19 -04:00
|
|
|
end
|
2016-07-12 19:18:13 -04:00
|
|
|
|
2016-07-20 18:45:19 -04:00
|
|
|
describe 'unsubscribe from issues' do
|
|
|
|
let(:issues) do
|
|
|
|
create_list(:closed_issue, 2, project: project) do |issue|
|
2016-10-31 22:14:53 -04:00
|
|
|
issue.subscriptions.create(user: user, project: project, subscribed: true)
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'unsubscribes the given user' do
|
2016-07-20 18:45:19 -04:00
|
|
|
bulk_update(issues, subscription_event: 'unsubscribe')
|
|
|
|
|
2016-07-12 19:18:13 -04:00
|
|
|
issues.each do |issue|
|
2016-11-04 14:19:08 -04:00
|
|
|
expect(issue).not_to be_subscribed(user, project)
|
2016-07-12 19:18:13 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-05-16 06:32:16 -04:00
|
|
|
end
|