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
5e5de233
Commit
5e5de233
authored
Jul 23, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if alert resolved before adding note
- Remove SystemNoteService addition - Small tidy ups
parent
32fd25ea
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
23 deletions
+8
-23
app/services/issues/close_service.rb
app/services/issues/close_service.rb
+4
-3
app/services/system_note_service.rb
app/services/system_note_service.rb
+0
-4
app/services/system_notes/alert_management_service.rb
app/services/system_notes/alert_management_service.rb
+1
-3
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+3
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+0
-12
No files found.
app/services/issues/close_service.rb
View file @
5e5de233
...
@@ -33,7 +33,7 @@ module Issues
...
@@ -33,7 +33,7 @@ module Issues
notification_service
.
async
.
close_issue
(
issue
,
current_user
,
closed_via:
closed_via
)
if
notifications
notification_service
.
async
.
close_issue
(
issue
,
current_user
,
closed_via:
closed_via
)
if
notifications
todo_service
.
close_issue
(
issue
,
current_user
)
todo_service
.
close_issue
(
issue
,
current_user
)
resolve_alert
(
issue
,
system_note
)
resolve_alert
(
issue
)
execute_hooks
(
issue
,
'close'
)
execute_hooks
(
issue
,
'close'
)
invalidate_cache_counts
(
issue
,
users:
issue
.
assignees
)
invalidate_cache_counts
(
issue
,
users:
issue
.
assignees
)
issue
.
update_project_counter_caches
issue
.
update_project_counter_caches
...
@@ -59,11 +59,12 @@ module Issues
...
@@ -59,11 +59,12 @@ module Issues
SystemNoteService
.
change_status
(
issue
,
issue
.
project
,
current_user
,
issue
.
state
,
current_commit
)
SystemNoteService
.
change_status
(
issue
,
issue
.
project
,
current_user
,
issue
.
state
,
current_commit
)
end
end
def
resolve_alert
(
issue
,
system_note
)
def
resolve_alert
(
issue
)
return
unless
alert
=
issue
.
alert_management_alert
return
unless
alert
=
issue
.
alert_management_alert
return
if
alert
.
resolved?
if
alert
.
resolve
if
alert
.
resolve
SystemNote
Service
.
closed_alert_issue
(
alert
,
issue
,
current_user
)
if
system_note
SystemNote
s
::
AlertManagementService
.
new
(
noteable:
alert
,
project:
alert
.
project
,
author:
current_user
).
closed_alert_issue
(
issue
)
else
else
Gitlab
::
AppLogger
.
warn
(
Gitlab
::
AppLogger
.
warn
(
message:
'Cannot resolve an associated Alert Management alert'
,
message:
'Cannot resolve an associated Alert Management alert'
,
...
...
app/services/system_note_service.rb
View file @
5e5de233
...
@@ -300,10 +300,6 @@ module SystemNoteService
...
@@ -300,10 +300,6 @@ module SystemNoteService
::
SystemNotes
::
AlertManagementService
.
new
(
noteable:
alert
,
project:
alert
.
project
,
author:
author
).
new_alert_issue
(
issue
)
::
SystemNotes
::
AlertManagementService
.
new
(
noteable:
alert
,
project:
alert
.
project
,
author:
author
).
new_alert_issue
(
issue
)
end
end
def
closed_alert_issue
(
alert
,
issue
,
author
)
::
SystemNotes
::
AlertManagementService
.
new
(
noteable:
alert
,
project:
alert
.
project
,
author:
author
).
closed_alert_issue
(
issue
)
end
private
private
def
merge_requests_service
(
noteable
,
project
,
author
)
def
merge_requests_service
(
noteable
,
project
,
author
)
...
...
app/services/system_notes/alert_management_service.rb
View file @
5e5de233
...
@@ -20,7 +20,6 @@ module SystemNotes
...
@@ -20,7 +20,6 @@ module SystemNotes
# Called when an issue is created based on an AlertManagement::Alert
# Called when an issue is created based on an AlertManagement::Alert
#
#
# alert - AlertManagement::Alert object.
# issue - Issue object.
# issue - Issue object.
#
#
# Example Note text:
# Example Note text:
...
@@ -34,9 +33,8 @@ module SystemNotes
...
@@ -34,9 +33,8 @@ module SystemNotes
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'alert_issue_added'
))
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'alert_issue_added'
))
end
end
# Called when an AlertManagement::Alert is resolved due to the associated
alert
being closed
# Called when an AlertManagement::Alert is resolved due to the associated
issue
being closed
#
#
# alert - AlertManagement::Alert object.
# issue - Issue object.
# issue - Issue object.
#
#
# Example Note text:
# Example Note text:
...
...
spec/services/issues/close_service_spec.rb
View file @
5e5de233
...
@@ -257,7 +257,9 @@ RSpec.describe Issues::CloseService do
...
@@ -257,7 +257,9 @@ RSpec.describe Issues::CloseService do
let!
(
:alert
)
{
create
(
:alert_management_alert
,
issue:
issue
,
project:
project
)
}
let!
(
:alert
)
{
create
(
:alert_management_alert
,
issue:
issue
,
project:
project
)
}
it
'resolves an alert and sends a system note'
do
it
'resolves an alert and sends a system note'
do
expect
(
SystemNoteService
).
to
receive
(
:closed_alert_issue
).
with
(
alert
,
issue
,
instance_of
(
User
))
expect_next_instance_of
(
SystemNotes
::
AlertManagementService
)
do
|
notes_service
|
expect
(
notes_service
).
to
receive
(
:closed_alert_issue
).
with
(
issue
)
end
close_issue
close_issue
...
...
spec/services/system_note_service_spec.rb
View file @
5e5de233
...
@@ -705,16 +705,4 @@ RSpec.describe SystemNoteService do
...
@@ -705,16 +705,4 @@ RSpec.describe SystemNoteService do
described_class
.
new_alert_issue
(
alert
,
alert
.
issue
,
author
)
described_class
.
new_alert_issue
(
alert
,
alert
.
issue
,
author
)
end
end
end
end
describe
'.closed_alert_issue'
do
let
(
:alert
)
{
build
(
:alert_management_alert
,
:with_issue
)
}
it
'calls AlertManagementService'
do
expect_next_instance_of
(
SystemNotes
::
AlertManagementService
)
do
|
service
|
expect
(
service
).
to
receive
(
:closed_alert_issue
).
with
(
alert
.
issue
)
end
described_class
.
closed_alert_issue
(
alert
,
alert
.
issue
,
author
)
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