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
b8881bd7
Commit
b8881bd7
authored
Aug 19, 2021
by
Sean Arnold
Committed by
Michael Kozono
Aug 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system note for issue type changes
Changelog: added
parent
e66837f0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
76 additions
and
8 deletions
+76
-8
app/helpers/system_note_helper.rb
app/helpers/system_note_helper.rb
+2
-1
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+11
-0
app/services/system_note_service.rb
app/services/system_note_service.rb
+4
-0
app/services/system_notes/issuables_service.rb
app/services/system_notes/issuables_service.rb
+6
-0
ee/app/services/ee/issues/update_service.rb
ee/app/services/ee/issues/update_service.rb
+3
-3
ee/spec/services/ee/issues/update_service_spec.rb
ee/spec/services/ee/issues/update_service_spec.rb
+18
-4
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+8
-0
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+12
-0
spec/services/system_notes/issuables_service_spec.rb
spec/services/system_notes/issuables_service_spec.rb
+12
-0
No files found.
app/helpers/system_note_helper.rb
View file @
b8881bd7
...
@@ -39,7 +39,8 @@ module SystemNoteHelper
...
@@ -39,7 +39,8 @@ module SystemNoteHelper
'alert_issue_added'
=>
'issues'
,
'alert_issue_added'
=>
'issues'
,
'new_alert_added'
=>
'warning'
,
'new_alert_added'
=>
'warning'
,
'severity'
=>
'information-o'
,
'severity'
=>
'information-o'
,
'cloned'
=>
'documents'
'cloned'
=>
'documents'
,
'issue_type'
=>
'pencil-square'
}.
freeze
}.
freeze
def
system_note_icon_name
(
note
)
def
system_note_icon_name
(
note
)
...
...
app/services/issues/update_service.rb
View file @
b8881bd7
...
@@ -77,6 +77,7 @@ module Issues
...
@@ -77,6 +77,7 @@ module Issues
end
end
handle_severity_change
(
issue
,
old_severity
)
handle_severity_change
(
issue
,
old_severity
)
handle_issue_type_change
(
issue
)
end
end
def
handle_assignee_changes
(
issue
,
old_assignees
)
def
handle_assignee_changes
(
issue
,
old_assignees
)
...
@@ -218,6 +219,16 @@ module Issues
...
@@ -218,6 +219,16 @@ module Issues
def
remove_incident_label?
(
issue
)
def
remove_incident_label?
(
issue
)
issue
.
issue_type
!=
params
[
:issue_type
]
&&
issue
.
incident?
issue
.
issue_type
!=
params
[
:issue_type
]
&&
issue
.
incident?
end
end
def
handle_issue_type_change
(
issue
)
return
unless
issue
.
previous_changes
.
include?
(
'issue_type'
)
do_handle_issue_type_change
(
issue
)
end
def
do_handle_issue_type_change
(
issue
)
SystemNoteService
.
change_issue_type
(
issue
,
current_user
)
end
end
end
end
end
...
...
app/services/system_note_service.rb
View file @
b8881bd7
...
@@ -331,6 +331,10 @@ module SystemNoteService
...
@@ -331,6 +331,10 @@ module SystemNoteService
::
SystemNotes
::
AlertManagementService
.
new
(
noteable:
alert
,
project:
alert
.
project
).
log_resolving_alert
(
monitoring_tool
)
::
SystemNotes
::
AlertManagementService
.
new
(
noteable:
alert
,
project:
alert
.
project
).
log_resolving_alert
(
monitoring_tool
)
end
end
def
change_issue_type
(
issue
,
author
)
::
SystemNotes
::
IssuablesService
.
new
(
noteable:
issue
,
project:
issue
.
project
,
author:
author
).
change_issue_type
end
private
private
def
merge_requests_service
(
noteable
,
project
,
author
)
def
merge_requests_service
(
noteable
,
project
,
author
)
...
...
app/services/system_notes/issuables_service.rb
View file @
b8881bd7
...
@@ -380,6 +380,12 @@ module SystemNotes
...
@@ -380,6 +380,12 @@ module SystemNotes
create_resource_state_event
(
status:
'closed'
,
close_auto_resolve_prometheus_alert:
true
)
create_resource_state_event
(
status:
'closed'
,
close_auto_resolve_prometheus_alert:
true
)
end
end
def
change_issue_type
body
=
"changed issue type to
#{
noteable
.
issue_type
.
humanize
(
capitalize:
false
)
}
"
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'issue_type'
))
end
private
private
def
cross_reference_note_content
(
gfm_reference
)
def
cross_reference_note_content
(
gfm_reference
)
...
...
ee/app/services/ee/issues/update_service.rb
View file @
b8881bd7
...
@@ -36,7 +36,6 @@ module EE
...
@@ -36,7 +36,6 @@ module EE
super
super
handle_iteration_change
(
issue
)
handle_iteration_change
(
issue
)
handle_issue_type_change
(
issue
)
end
end
private
private
...
@@ -55,8 +54,9 @@ module EE
...
@@ -55,8 +54,9 @@ module EE
end
end
end
end
def
handle_issue_type_change
(
issue
)
override
:do_handle_issue_type_change
return
unless
issue
.
previous_changes
.
include?
(
'issue_type'
)
def
do_handle_issue_type_change
(
issue
)
super
::
IncidentManagement
::
Incidents
::
CreateSlaService
.
new
(
issue
,
current_user
).
execute
::
IncidentManagement
::
Incidents
::
CreateSlaService
.
new
(
issue
,
current_user
).
execute
end
end
...
...
ee/spec/services/ee/issues/update_service_spec.rb
View file @
b8881bd7
...
@@ -179,10 +179,24 @@ RSpec.describe Issues::UpdateService do
...
@@ -179,10 +179,24 @@ RSpec.describe Issues::UpdateService do
end
end
context
'from issue to incident'
do
context
'from issue to incident'
do
it
'creates an SLA'
do
shared_examples
'creates an SLA'
do
expect
{
update_issue
(
issue_type:
'incident'
)
}.
to
change
(
IssuableSla
,
:count
).
by
(
1
)
it
do
expect
(
issue
.
reload
).
to
be_incident
expect
{
update_issue
(
issue_type:
'incident'
)
}.
to
change
(
IssuableSla
,
:count
).
by
(
1
)
expect
(
issue
.
reload
.
issuable_sla
).
to
be_present
expect
(
issue
.
reload
).
to
be_incident
expect
(
issue
.
reload
.
issuable_sla
).
to
be_present
end
end
it_behaves_like
'creates an SLA'
context
'system note fails to be created'
do
before
do
expect_next_instance_of
(
Note
)
do
|
note
|
expect
(
note
).
to
receive
(
:valid?
).
and_return
(
false
)
end
end
it_behaves_like
'creates an SLA'
end
end
end
end
...
...
spec/services/issues/update_service_spec.rb
View file @
b8881bd7
...
@@ -189,6 +189,14 @@ RSpec.describe Issues::UpdateService, :mailer do
...
@@ -189,6 +189,14 @@ RSpec.describe Issues::UpdateService, :mailer do
expect
(
issue
.
labels
.
pluck
(
:title
)).
to
eq
([
'incident'
])
expect
(
issue
.
labels
.
pluck
(
:title
)).
to
eq
([
'incident'
])
end
end
it
'creates system note about issue type'
do
update_issue
(
issue_type:
'incident'
)
note
=
find_note
(
'changed issue type to incident'
)
expect
(
note
).
not_to
eq
(
nil
)
end
context
'for an issue with multiple labels'
do
context
'for an issue with multiple labels'
do
let
(
:issue
)
{
create
(
:incident
,
project:
project
,
labels:
[
label_1
])
}
let
(
:issue
)
{
create
(
:incident
,
project:
project
,
labels:
[
label_1
])
}
...
...
spec/services/system_note_service_spec.rb
View file @
b8881bd7
...
@@ -793,4 +793,16 @@ RSpec.describe SystemNoteService do
...
@@ -793,4 +793,16 @@ RSpec.describe SystemNoteService do
described_class
.
log_resolving_alert
(
alert
,
monitoring_tool
)
described_class
.
log_resolving_alert
(
alert
,
monitoring_tool
)
end
end
end
end
describe
'.change_issue_type'
do
let
(
:incident
)
{
build
(
:incident
)
}
it
'calls IssuableService'
do
expect_next_instance_of
(
::
SystemNotes
::
IssuablesService
)
do
|
service
|
expect
(
service
).
to
receive
(
:change_issue_type
)
end
described_class
.
change_issue_type
(
incident
,
author
)
end
end
end
end
spec/services/system_notes/issuables_service_spec.rb
View file @
b8881bd7
...
@@ -773,4 +773,16 @@ RSpec.describe ::SystemNotes::IssuablesService do
...
@@ -773,4 +773,16 @@ RSpec.describe ::SystemNotes::IssuablesService do
expect
(
event
.
state
).
to
eq
(
'closed'
)
expect
(
event
.
state
).
to
eq
(
'closed'
)
end
end
end
end
describe
'#change_issue_type'
do
let
(
:noteable
)
{
create
(
:incident
,
project:
project
)
}
subject
{
service
.
change_issue_type
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'issue_type'
}
end
it
{
expect
(
subject
.
note
).
to
eq
"changed issue type to incident"
}
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