Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/issues/update_service_spec.rb')
-rw-r--r--spec/services/issues/update_service_spec.rb90
1 files changed, 87 insertions, 3 deletions
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 8c97dd95ced..b95d94e3784 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -158,6 +158,90 @@ RSpec.describe Issues::UpdateService, :mailer do
end
end
+ context 'changing issue_type' do
+ let!(:label_1) { create(:label, project: project, title: 'incident') }
+ let!(:label_2) { create(:label, project: project, title: 'missed-sla') }
+
+ before do
+ stub_licensed_features(quality_management: true)
+ end
+
+ context 'from issue to incident' do
+ it 'adds a `incident` label if one does not exist' do
+ expect { update_issue(issue_type: 'incident') }.to change(issue.labels, :count).by(1)
+ expect(issue.labels.pluck(:title)).to eq(['incident'])
+ end
+
+ context 'for an issue with multiple labels' do
+ let(:issue) { create(:incident, project: project, labels: [label_1]) }
+
+ before do
+ update_issue(issue_type: 'incident')
+ end
+
+ it 'does not add an `incident` label if one already exist' do
+ expect(issue.labels).to eq([label_1])
+ end
+ end
+
+ context 'filtering the incident label' do
+ let(:params) { { add_label_ids: [] } }
+
+ before do
+ update_issue(issue_type: 'incident')
+ end
+
+ it 'creates and add a incident label id to add_label_ids' do
+ expect(issue.label_ids).to contain_exactly(label_1.id)
+ end
+ end
+ end
+
+ context 'from incident to issue' do
+ let(:issue) { create(:incident, project: project) }
+
+ context 'for an incident with multiple labels' do
+ let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) }
+
+ before do
+ update_issue(issue_type: 'issue')
+ end
+
+ it 'removes an `incident` label if one exists on the incident' do
+ expect(issue.labels).to eq([label_2])
+ end
+ end
+
+ context 'filtering the incident label' do
+ let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) }
+ let(:params) { { label_ids: [label_1.id, label_2.id], remove_label_ids: [] } }
+
+ before do
+ update_issue(issue_type: 'issue')
+ end
+
+ it 'adds an incident label id to remove_label_ids for it to be removed' do
+ expect(issue.label_ids).to contain_exactly(label_2.id)
+ end
+ end
+ end
+
+ context 'from issue to restricted issue types' do
+ context 'without sufficient permissions' do
+ let(:user) { create(:user) }
+
+ before do
+ project.add_guest(user)
+ end
+
+ it 'does nothing to the labels' do
+ expect { update_issue(issue_type: 'issue') }.not_to change(issue.labels, :count)
+ expect(issue.reload.labels).to eq([])
+ end
+ end
+ end
+ end
+
it 'updates open issue counter for assignees when issue is reassigned' do
update_issue(assignee_ids: [user2.id])
@@ -225,7 +309,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts[:move_between_ids] = [issue1.id, issue2.id]
- expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id)
+ expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, nil, project.root_namespace.id)
update_issue(opts)
expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position)
@@ -239,7 +323,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts[:move_between_ids] = [issue1.id, issue2.id]
- expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id)
+ expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, nil, project.root_namespace.id)
update_issue(opts)
expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position)
@@ -253,7 +337,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts[:move_between_ids] = [issue1.id, issue2.id]
- expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id)
+ expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, nil, project.root_namespace.id)
update_issue(opts)
expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position)