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/incident_management')
-rw-r--r--spec/services/incident_management/incidents/create_service_spec.rb4
-rw-r--r--spec/services/incident_management/issuable_escalation_statuses/prepare_update_service_spec.rb15
-rw-r--r--spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb2
-rw-r--r--spec/services/incident_management/timeline_events/create_service_spec.rb84
-rw-r--r--spec/services/incident_management/timeline_events/destroy_service_spec.rb22
-rw-r--r--spec/services/incident_management/timeline_events/update_service_spec.rb16
6 files changed, 53 insertions, 90 deletions
diff --git a/spec/services/incident_management/incidents/create_service_spec.rb b/spec/services/incident_management/incidents/create_service_spec.rb
index ac44bc4608c..851b21e1227 100644
--- a/spec/services/incident_management/incidents/create_service_spec.rb
+++ b/spec/services/incident_management/incidents/create_service_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
it 'responds with errors' do
expect(create_incident).to be_error
- expect(create_incident.message).to eq("Title can't be blank")
+ expect(create_incident.errors).to contain_exactly("Title can't be blank")
end
it 'result payload contains an Issue object' do
@@ -98,7 +98,7 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
it 'responds with errors' do
expect(create_incident).to be_error
- expect(create_incident.message).to eq('Hosts hosts array is over 255 chars')
+ expect(create_incident.errors).to contain_exactly('Hosts hosts array is over 255 chars')
end
end
end
diff --git a/spec/services/incident_management/issuable_escalation_statuses/prepare_update_service_spec.rb b/spec/services/incident_management/issuable_escalation_statuses/prepare_update_service_spec.rb
index 761cc5c92ea..e8208c410d5 100644
--- a/spec/services/incident_management/issuable_escalation_statuses/prepare_update_service_spec.rb
+++ b/spec/services/incident_management/issuable_escalation_statuses/prepare_update_service_spec.rb
@@ -2,7 +2,8 @@
require 'spec_helper'
-RSpec.describe IncidentManagement::IssuableEscalationStatuses::PrepareUpdateService do
+RSpec.describe IncidentManagement::IssuableEscalationStatuses::PrepareUpdateService, factory_default: :keep do
+ let_it_be(:project) { create_default(:project) }
let_it_be(:escalation_status) { create(:incident_management_issuable_escalation_status, :triggered) }
let_it_be(:user_with_permissions) { create(:user) }
@@ -10,7 +11,7 @@ RSpec.describe IncidentManagement::IssuableEscalationStatuses::PrepareUpdateServ
let(:issue) { escalation_status.issue }
let(:status) { :acknowledged }
let(:params) { { status: status } }
- let(:service) { IncidentManagement::IssuableEscalationStatuses::PrepareUpdateService.new(issue, current_user, params) }
+ let(:service) { described_class.new(issue, current_user, params) }
subject(:result) { service.execute }
@@ -71,9 +72,17 @@ RSpec.describe IncidentManagement::IssuableEscalationStatuses::PrepareUpdateServ
end
end
- context 'when called without params' do
+ context 'when called nil params' do
let(:params) { nil }
+ it 'raises an exception' do
+ expect { result }.to raise_error NoMethodError
+ end
+ end
+
+ context 'when called without params' do
+ let(:params) { {} }
+
it_behaves_like 'successful response', {}
end
diff --git a/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb b/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb
index fb536df5d17..572b1a20166 100644
--- a/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb
+++ b/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb
@@ -63,7 +63,7 @@ RSpec.describe IncidentManagement::PagerDuty::CreateIncidentIssueService do
it 'responds with error' do
expect(execute).to be_error
- expect(execute.message).to eq("Title can't be blank")
+ expect(execute.errors).to contain_exactly("Title can't be blank")
end
end
end
diff --git a/spec/services/incident_management/timeline_events/create_service_spec.rb b/spec/services/incident_management/timeline_events/create_service_spec.rb
index b999403e168..a7f448c825f 100644
--- a/spec/services/incident_management/timeline_events/create_service_spec.rb
+++ b/spec/services/incident_management/timeline_events/create_service_spec.rb
@@ -71,7 +71,7 @@ RSpec.describe IncidentManagement::TimelineEvents::CreateService do
context 'when error occurs during creation' do
let(:args) { {} }
- it_behaves_like 'error response', "Occurred at can't be blank, Note can't be blank, and Note html can't be blank"
+ it_behaves_like 'error response', "Occurred at can't be blank and Timeline text can't be blank"
end
context 'with default action' do
@@ -84,50 +84,6 @@ RSpec.describe IncidentManagement::TimelineEvents::CreateService do
expect(result.action).to eq(IncidentManagement::TimelineEvents::DEFAULT_ACTION)
end
- end
-
- context 'with non_default action' do
- it_behaves_like 'success response'
-
- it 'matches the action from arguments', :aggregate_failures do
- result = execute.payload[:timeline_event]
-
- expect(result.action).to eq(args[:action])
- end
- end
-
- context 'with editable param' do
- let(:args) do
- {
- note: 'note',
- occurred_at: Time.current,
- action: 'new comment',
- promoted_from_note: comment,
- editable: editable
- }
- end
-
- context 'when editable is true' do
- let(:editable) { true }
-
- it_behaves_like 'success response'
- end
-
- context 'when editable is false' do
- let(:editable) { false }
-
- it_behaves_like 'success response'
- end
- end
-
- it 'successfully creates a database record', :aggregate_failures do
- expect { execute }.to change { ::IncidentManagement::TimelineEvent.count }.by(1)
- end
-
- context 'when incident_timeline feature flag is enabled' do
- before do
- stub_feature_flags(incident_timeline: project)
- end
it 'creates a system note' do
expect { execute }.to change { incident.notes.reload.count }.by(1)
@@ -168,14 +124,42 @@ RSpec.describe IncidentManagement::TimelineEvents::CreateService do
end
end
- context 'when incident_timeline feature flag is disabled' do
- before do
- stub_feature_flags(incident_timeline: false)
+ context 'with non_default action' do
+ it_behaves_like 'success response'
+
+ it 'matches the action from arguments', :aggregate_failures do
+ result = execute.payload[:timeline_event]
+
+ expect(result.action).to eq(args[:action])
end
+ end
- it 'does not create a system note' do
- expect { execute }.not_to change { incident.notes.reload.count }
+ context 'with editable param' do
+ let(:args) do
+ {
+ note: 'note',
+ occurred_at: Time.current,
+ action: 'new comment',
+ promoted_from_note: comment,
+ editable: editable
+ }
+ end
+
+ context 'when editable is true' do
+ let(:editable) { true }
+
+ it_behaves_like 'success response'
end
+
+ context 'when editable is false' do
+ let(:editable) { false }
+
+ it_behaves_like 'success response'
+ end
+ end
+
+ it 'successfully creates a database record', :aggregate_failures do
+ expect { execute }.to change { ::IncidentManagement::TimelineEvent.count }.by(1)
end
end
diff --git a/spec/services/incident_management/timeline_events/destroy_service_spec.rb b/spec/services/incident_management/timeline_events/destroy_service_spec.rb
index 09026f87116..e1b258960ae 100644
--- a/spec/services/incident_management/timeline_events/destroy_service_spec.rb
+++ b/spec/services/incident_management/timeline_events/destroy_service_spec.rb
@@ -48,10 +48,10 @@ RSpec.describe IncidentManagement::TimelineEvents::DestroyService do
timeline_event.errors.add(:note, 'cannot be removed')
end
- it_behaves_like 'error response', 'Note cannot be removed'
+ it_behaves_like 'error response', 'Timeline text cannot be removed'
end
- context 'success response' do
+ context 'with success response' do
it 'successfully returns the timeline event', :aggregate_failures do
expect(execute).to be_success
@@ -60,27 +60,11 @@ RSpec.describe IncidentManagement::TimelineEvents::DestroyService do
expect(result.id).to eq(timeline_event.id)
end
- it_behaves_like 'an incident management tracked event', :incident_management_timeline_event_deleted
- end
-
- context 'when incident_timeline feature flag is enabled' do
- before do
- stub_feature_flags(incident_timeline: project)
- end
-
it 'creates a system note' do
expect { execute }.to change { incident.notes.reload.count }.by(1)
end
- end
-
- context 'when incident_timeline feature flag is disabled' do
- before do
- stub_feature_flags(incident_timeline: false)
- end
- it 'does not create a system note' do
- expect { execute }.not_to change { incident.notes.reload.count }
- end
+ it_behaves_like 'an incident management tracked event', :incident_management_timeline_event_deleted
end
end
end
diff --git a/spec/services/incident_management/timeline_events/update_service_spec.rb b/spec/services/incident_management/timeline_events/update_service_spec.rb
index f612c72e2a8..5d8518cf2ef 100644
--- a/spec/services/incident_management/timeline_events/update_service_spec.rb
+++ b/spec/services/incident_management/timeline_events/update_service_spec.rb
@@ -12,10 +12,6 @@ RSpec.describe IncidentManagement::TimelineEvents::UpdateService do
let(:params) { { note: 'Updated note', occurred_at: occurred_at } }
let(:current_user) { user }
- before do
- stub_feature_flags(incident_timeline: project)
- end
-
describe '#execute' do
shared_examples 'successful response' do
it 'responds with success', :aggregate_failures do
@@ -70,16 +66,6 @@ RSpec.describe IncidentManagement::TimelineEvents::UpdateService do
it_behaves_like 'passing the correct was_changed value', :occurred_at_and_note
- context 'when incident_timeline feature flag is disabled' do
- before do
- stub_feature_flags(incident_timeline: false)
- end
-
- it 'does not add a system note' do
- expect { execute }.not_to change { incident.notes }
- end
- end
-
context 'when note is nil' do
let(:params) { { occurred_at: occurred_at } }
@@ -98,7 +84,7 @@ RSpec.describe IncidentManagement::TimelineEvents::UpdateService do
context 'when note is blank' do
let(:params) { { note: '', occurred_at: occurred_at } }
- it_behaves_like 'error response', "Note can't be blank"
+ it_behaves_like 'error response', "Timeline text can't be blank"
end
context 'when occurred_at is nil' do