2013-05-15 13:59:15 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-01-16 18:29:18 +00:00
|
|
|
describe Issues::BulkUpdateService do
|
2015-06-22 20:00:54 +00:00
|
|
|
let(:issue) { create(:issue, project: @project) }
|
2013-05-16 10:32:16 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
@user = create :user
|
|
|
|
opts = {
|
2013-09-17 13:12:10 +00:00
|
|
|
name: "GitLab",
|
|
|
|
namespace: @user.namespace
|
2013-05-16 10:32:16 +00:00
|
|
|
}
|
2014-01-16 18:29:18 +00:00
|
|
|
@project = Projects::CreateService.new(@user, opts).execute
|
2013-05-16 10:32:16 +00:00
|
|
|
end
|
|
|
|
|
2013-05-15 13:59:15 +00:00
|
|
|
describe :close_issue do
|
|
|
|
|
|
|
|
before do
|
|
|
|
@issues = 5.times.collect do
|
|
|
|
create(:issue, project: @project)
|
|
|
|
end
|
2014-06-17 19:51:43 +00:00
|
|
|
@params = {
|
2015-03-06 14:01:13 +00:00
|
|
|
state_event: 'close',
|
|
|
|
issues_ids: @issues.map(&:id)
|
2013-05-15 13:59:15 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-06-22 20:00:54 +00:00
|
|
|
it do
|
2014-01-16 18:29:18 +00:00
|
|
|
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(result[:success]).to be_truthy
|
|
|
|
expect(result[:count]).to eq(@issues.count)
|
2013-05-16 10:32:16 +00:00
|
|
|
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(@project.issues.opened).to be_empty
|
|
|
|
expect(@project.issues.closed).not_to be_empty
|
2015-06-22 20:00:54 +00:00
|
|
|
end
|
2013-05-15 13:59:15 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe :reopen_issues do
|
|
|
|
|
|
|
|
before do
|
|
|
|
@issues = 5.times.collect do
|
|
|
|
create(:closed_issue, project: @project)
|
|
|
|
end
|
2014-06-17 19:51:43 +00:00
|
|
|
@params = {
|
2015-03-06 14:01:13 +00:00
|
|
|
state_event: 'reopen',
|
|
|
|
issues_ids: @issues.map(&:id)
|
2013-05-15 13:59:15 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-06-22 20:00:54 +00:00
|
|
|
it do
|
2014-01-16 18:29:18 +00:00
|
|
|
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(result[:success]).to be_truthy
|
|
|
|
expect(result[:count]).to eq(@issues.count)
|
2013-05-16 10:32:16 +00:00
|
|
|
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(@project.issues.closed).to be_empty
|
|
|
|
expect(@project.issues.opened).not_to be_empty
|
2015-06-22 20:00:54 +00:00
|
|
|
end
|
2013-05-16 10:32:16 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe :update_assignee do
|
|
|
|
|
|
|
|
before do
|
|
|
|
@new_assignee = create :user
|
2014-06-17 19:51:43 +00:00
|
|
|
@params = {
|
2015-03-06 14:01:13 +00:00
|
|
|
issues_ids: [issue.id],
|
|
|
|
assignee_id: @new_assignee.id
|
2013-05-16 10:32:16 +00:00
|
|
|
}
|
2013-05-15 13:59:15 +00:00
|
|
|
end
|
|
|
|
|
2015-06-22 20:00:54 +00:00
|
|
|
it do
|
2014-01-16 18:29:18 +00:00
|
|
|
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(result[:success]).to be_truthy
|
|
|
|
expect(result[:count]).to eq(1)
|
2013-05-16 10:32:16 +00:00
|
|
|
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(@project.issues.first.assignee).to eq(@new_assignee)
|
2015-06-22 20:00:54 +00:00
|
|
|
end
|
2013-05-15 13:59:15 +00:00
|
|
|
|
2015-02-25 09:29:33 +00:00
|
|
|
it 'allows mass-unassigning' do
|
|
|
|
@project.issues.first.update_attribute(:assignee, @new_assignee)
|
|
|
|
expect(@project.issues.first.assignee).not_to be_nil
|
|
|
|
|
2015-03-06 14:01:13 +00:00
|
|
|
@params[:assignee_id] = -1
|
2015-02-25 09:29:33 +00:00
|
|
|
|
|
|
|
Issues::BulkUpdateService.new(@project, @user, @params).execute
|
|
|
|
expect(@project.issues.first.assignee).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not unassign when assignee_id is not present' do
|
|
|
|
@project.issues.first.update_attribute(:assignee, @new_assignee)
|
|
|
|
expect(@project.issues.first.assignee).not_to be_nil
|
|
|
|
|
2015-03-06 14:01:13 +00:00
|
|
|
@params[:assignee_id] = ''
|
2015-02-25 09:29:33 +00:00
|
|
|
|
|
|
|
Issues::BulkUpdateService.new(@project, @user, @params).execute
|
|
|
|
expect(@project.issues.first.assignee).not_to be_nil
|
|
|
|
end
|
2013-05-15 13:59:15 +00:00
|
|
|
end
|
|
|
|
|
2013-05-16 10:32:16 +00:00
|
|
|
describe :update_milestone do
|
|
|
|
|
|
|
|
before do
|
|
|
|
@milestone = create :milestone
|
2014-06-17 19:51:43 +00:00
|
|
|
@params = {
|
2015-03-06 14:01:13 +00:00
|
|
|
issues_ids: [issue.id],
|
|
|
|
milestone_id: @milestone.id
|
2013-05-16 10:32:16 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-06-22 20:00:54 +00:00
|
|
|
it do
|
2014-01-16 18:29:18 +00:00
|
|
|
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(result[:success]).to be_truthy
|
|
|
|
expect(result[:count]).to eq(1)
|
2013-05-16 10:32:16 +00:00
|
|
|
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(@project.issues.first.milestone).to eq(@milestone)
|
2015-06-22 20:00:54 +00:00
|
|
|
end
|
2013-05-15 13:59:15 +00:00
|
|
|
end
|
|
|
|
|
2013-05-16 10:32:16 +00:00
|
|
|
end
|