Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
15ef1d80
Commit
15ef1d80
authored
Sep 15, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system note on change incident severity
parent
011f15a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
app/services/incident_management/incidents/update_severity_service.rb
.../incident_management/incidents/update_severity_service.rb
+10
-1
spec/services/incident_management/incidents/update_severity_service_spec.rb
...dent_management/incidents/update_severity_service_spec.rb
+17
-1
No files found.
app/services/incident_management/incidents/update_severity_service.rb
View file @
15ef1d80
...
@@ -14,7 +14,8 @@ module IncidentManagement
...
@@ -14,7 +14,8 @@ module IncidentManagement
def
execute
def
execute
return
unless
issuable
.
incident?
return
unless
issuable
.
incident?
issuable_severity
.
update
(
severity:
severity
)
update_severity!
add_system_note
end
end
private
private
...
@@ -24,6 +25,14 @@ module IncidentManagement
...
@@ -24,6 +25,14 @@ module IncidentManagement
def
issuable_severity
def
issuable_severity
issuable
.
issuable_severity
||
issuable
.
build_issuable_severity
(
issue_id:
issuable
.
id
)
issuable
.
issuable_severity
||
issuable
.
build_issuable_severity
(
issue_id:
issuable
.
id
)
end
end
def
update_severity!
issuable_severity
.
update!
(
severity:
severity
)
end
def
add_system_note
SystemNoteService
.
change_incident_severity
(
issuable
,
current_user
)
end
end
end
end
end
end
end
spec/services/incident_management/incidents/update_severity_service_spec.rb
View file @
15ef1d80
...
@@ -10,6 +10,12 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
...
@@ -10,6 +10,12 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
subject
(
:update_severity
)
{
described_class
.
new
(
issuable
,
user
,
severity
).
execute
}
subject
(
:update_severity
)
{
described_class
.
new
(
issuable
,
user
,
severity
).
execute
}
shared_examples
'adds a system note'
do
it
do
expect
{
update_severity
}.
to
change
{
issuable
.
notes
.
where
(
author:
user
).
count
}.
by
(
1
)
end
end
context
'when issuable not an incident'
do
context
'when issuable not an incident'
do
%i(issue merge_request)
.
each
do
|
issuable_type
|
%i(issue merge_request)
.
each
do
|
issuable_type
|
let
(
:issuable
)
{
build_stubbed
(
issuable_type
)
}
let
(
:issuable
)
{
build_stubbed
(
issuable_type
)
}
...
@@ -17,7 +23,11 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
...
@@ -17,7 +23,11 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
it
'does not set severity'
do
it
'does not set severity'
do
expect
{
subject
}.
not_to
change
(
IssuableSeverity
,
:count
)
expect
{
update_severity
}.
not_to
change
(
IssuableSeverity
,
:count
)
end
it
'does not add a system note'
do
expect
{
update_severity
}.
not_to
change
{
issuable
.
notes
.
count
}
end
end
end
end
end
end
...
@@ -33,6 +43,8 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
...
@@ -33,6 +43,8 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
it
'sets severity to specified value'
do
it
'sets severity to specified value'
do
expect
{
update_severity
}.
to
change
{
issuable
.
severity
}.
to
(
'low'
)
expect
{
update_severity
}.
to
change
{
issuable
.
severity
}.
to
(
'low'
)
end
end
it_behaves_like
'adds a system note'
end
end
context
'when issuable has an issuable severity'
do
context
'when issuable has an issuable severity'
do
...
@@ -45,6 +57,8 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
...
@@ -45,6 +57,8 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
it
'updates existing issuable severity'
do
it
'updates existing issuable severity'
do
expect
{
update_severity
}.
to
change
{
issuable_severity
.
severity
}.
to
(
severity
)
expect
{
update_severity
}.
to
change
{
issuable_severity
.
severity
}.
to
(
severity
)
end
end
it_behaves_like
'adds a system note'
end
end
context
'when severity value is unsupported'
do
context
'when severity value is unsupported'
do
...
@@ -55,6 +69,8 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
...
@@ -55,6 +69,8 @@ RSpec.describe IncidentManagement::Incidents::UpdateSeverityService do
expect
(
issuable
.
issuable_severity
.
severity
).
to
eq
(
IssuableSeverity
::
DEFAULT
)
expect
(
issuable
.
issuable_severity
.
severity
).
to
eq
(
IssuableSeverity
::
DEFAULT
)
end
end
it_behaves_like
'adds a system note'
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment