Commit 9aa4267b authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Merge branch 'incident-label' into 'master'

Remove adding of incident label

See merge request gitlab-org/gitlab!78258
parents 66f24a97 d4a57b8f
...@@ -46,7 +46,6 @@ module Issues ...@@ -46,7 +46,6 @@ module Issues
super super
params.delete(:issue_type) unless create_issue_type_allowed?(issue, params[:issue_type]) params.delete(:issue_type) unless create_issue_type_allowed?(issue, params[:issue_type])
filter_incident_label(issue) if params[:issue_type]
moved_issue = params.delete(:moved_issue) moved_issue = params.delete(:moved_issue)
...@@ -89,37 +88,6 @@ module Issues ...@@ -89,37 +88,6 @@ module Issues
Milestones::IssuesCountService.new(milestone).delete_cache Milestones::IssuesCountService.new(milestone).delete_cache
end end
# @param issue [Issue]
def filter_incident_label(issue)
return unless add_incident_label?(issue) || remove_incident_label?(issue)
label = ::IncidentManagement::CreateIncidentLabelService
.new(project, current_user)
.execute
.payload[:label]
# These(add_label_ids, remove_label_ids) are being added ahead of time
# to be consumed by #process_label_ids, this allows system notes
# to be applied correctly alongside the label updates.
if add_incident_label?(issue)
params[:add_label_ids] ||= []
params[:add_label_ids] << label.id
else
params[:remove_label_ids] ||= []
params[:remove_label_ids] << label.id
end
end
# @param issue [Issue]
def add_incident_label?(issue)
issue.incident?
end
# @param _issue [Issue, nil]
def remove_incident_label?(_issue)
false
end
end end
end end
......
...@@ -236,16 +236,6 @@ module Issues ...@@ -236,16 +236,6 @@ module Issues
SystemNoteService.change_issue_confidentiality(issue, issue.project, current_user) SystemNoteService.change_issue_confidentiality(issue, issue.project, current_user)
end end
override :add_incident_label?
def add_incident_label?(issue)
issue.issue_type != params[:issue_type] && !issue.incident?
end
override :remove_incident_label?
def remove_incident_label?(issue)
issue.issue_type != params[:issue_type] && issue.incident?
end
def handle_issue_type_change(issue) def handle_issue_type_change(issue)
return unless issue.previous_changes.include?('issue_type') return unless issue.previous_changes.include?('issue_type')
......
...@@ -39,7 +39,7 @@ RSpec.describe IncidentManagement::Incidents::CreateService do ...@@ -39,7 +39,7 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
let(:issue) { new_issue } let(:issue) { new_issue }
include_examples 'has incident label' include_examples 'does not have incident label'
end end
context 'with default severity' do context 'with default severity' do
...@@ -71,8 +71,8 @@ RSpec.describe IncidentManagement::Incidents::CreateService do ...@@ -71,8 +71,8 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
end end
context 'when incident label does not exists' do context 'when incident label does not exists' do
it 'creates incident label' do it 'does not create incident label' do
expect { create_incident }.to change { project.labels.where(title: label_title).count }.by(1) expect { create_incident }.to not_change { project.labels.where(title: label_title).count }
end end
end end
......
...@@ -114,11 +114,11 @@ RSpec.describe Issues::CreateService do ...@@ -114,11 +114,11 @@ RSpec.describe Issues::CreateService do
end end
it_behaves_like 'incident issue' it_behaves_like 'incident issue'
it_behaves_like 'has incident label' it_behaves_like 'does not have incident label'
it 'does create an incident label' do it 'does not create an incident label' do
expect { subject } expect { subject }
.to change { Label.where(incident_label_attributes).count }.by(1) .to not_change { Label.where(incident_label_attributes).count }
end end
it 'calls IncidentManagement::Incidents::CreateEscalationStatusService' do it 'calls IncidentManagement::Incidents::CreateEscalationStatusService' do
......
...@@ -191,11 +191,6 @@ RSpec.describe Issues::UpdateService, :mailer do ...@@ -191,11 +191,6 @@ RSpec.describe Issues::UpdateService, :mailer do
end end
end end
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
it 'creates system note about issue type' do it 'creates system note about issue type' do
update_issue(issue_type: 'incident') update_issue(issue_type: 'incident')
...@@ -222,18 +217,6 @@ RSpec.describe Issues::UpdateService, :mailer do ...@@ -222,18 +217,6 @@ RSpec.describe Issues::UpdateService, :mailer do
expect(issue.labels).to eq([label_1]) expect(issue.labels).to eq([label_1])
end end
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 end
context 'from incident to issue' do context 'from incident to issue' do
...@@ -248,10 +231,8 @@ RSpec.describe Issues::UpdateService, :mailer do ...@@ -248,10 +231,8 @@ RSpec.describe Issues::UpdateService, :mailer do
context 'for an incident with multiple labels' do context 'for an incident with multiple labels' do
let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) } let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) }
it 'removes an `incident` label if one exists on the incident' do it 'does not remove an `incident` label if one exists on the incident' do
expect { update_issue(issue_type: 'issue') }.to change(issue, :label_ids) expect { update_issue(issue_type: 'issue') }.to not_change(issue, :label_ids)
.from(containing_exactly(label_1.id, label_2.id))
.to([label_2.id])
end end
end end
...@@ -259,10 +240,8 @@ RSpec.describe Issues::UpdateService, :mailer do ...@@ -259,10 +240,8 @@ RSpec.describe Issues::UpdateService, :mailer do
let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) } let(:issue) { create(:incident, project: project, labels: [label_1, label_2]) }
let(:params) { { label_ids: [label_1.id, label_2.id], remove_label_ids: [] } } let(:params) { { label_ids: [label_1.id, label_2.id], remove_label_ids: [] } }
it 'adds an incident label id to remove_label_ids for it to be removed' do it 'does not add an incident label id to remove_label_ids for it to be removed' do
expect { update_issue(issue_type: 'issue') }.to change(issue, :label_ids) expect { update_issue(issue_type: 'issue') }.to not_change(issue, :label_ids)
.from(containing_exactly(label_1.id, label_2.id))
.to([label_2.id])
end end
end end
end end
......
...@@ -17,16 +17,6 @@ RSpec.shared_examples 'incident issue' do ...@@ -17,16 +17,6 @@ RSpec.shared_examples 'incident issue' do
end end
end end
RSpec.shared_examples 'has incident label' do
let(:label_properties) { attributes_for(:label, :incident) }
it 'has exactly one incident label' do
expect(issue.labels).to be_one do |label|
label.slice(*label_properties.keys).symbolize_keys == label_properties
end
end
end
# This shared_example requires the following variables: # This shared_example requires the following variables:
# - issue (required) # - issue (required)
# #
...@@ -45,6 +35,12 @@ RSpec.shared_examples 'not an incident issue' do ...@@ -45,6 +35,12 @@ RSpec.shared_examples 'not an incident issue' do
expect(issue.work_item_type.base_type).not_to eq('incident') expect(issue.work_item_type.base_type).not_to eq('incident')
end end
it_behaves_like 'does not have incident label'
end
RSpec.shared_examples 'does not have incident label' do
let(:label_properties) { attributes_for(:label, :incident) }
it 'has not an incident label' do it 'has not an incident label' do
expect(issue.labels).not_to include(have_attributes(label_properties)) expect(issue.labels).not_to include(have_attributes(label_properties))
end end
......
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