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
2616e2da
Commit
2616e2da
authored
Aug 24, 2021
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send rotation email inline when deleting user
Changelog: fixed EE: true
parent
cfdec1f8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
11 deletions
+26
-11
ee/app/services/ee/notification_service.rb
ee/app/services/ee/notification_service.rb
+3
-2
ee/app/services/ee/users/destroy_service.rb
ee/app/services/ee/users/destroy_service.rb
+2
-1
ee/app/services/incident_management/oncall_rotations/remove_participant_service.rb
...management/oncall_rotations/remove_participant_service.rb
+5
-3
ee/app/services/incident_management/oncall_rotations/remove_participants_service.rb
...anagement/oncall_rotations/remove_participants_service.rb
+5
-3
ee/spec/services/ee/notification_service_spec.rb
ee/spec/services/ee/notification_service_spec.rb
+4
-0
ee/spec/services/ee/users/destroy_service_spec.rb
ee/spec/services/ee/users/destroy_service_spec.rb
+5
-0
ee/spec/services/incident_management/oncall_rotations/remove_participants_service_spec.rb
...ment/oncall_rotations/remove_participants_service_spec.rb
+2
-2
No files found.
ee/app/services/ee/notification_service.rb
View file @
2616e2da
...
...
@@ -76,9 +76,10 @@ module EE
end
end
def
oncall_user_removed
(
rotation
,
user
)
def
oncall_user_removed
(
rotation
,
user
,
async
=
true
)
project_owners_and_participants
(
rotation
,
user
).
each
do
|
recipient
|
mailer
.
user_removed_from_rotation_email
(
user
,
rotation
,
[
recipient
]).
deliver_later
email
=
mailer
.
user_removed_from_rotation_email
(
user
,
rotation
,
[
recipient
])
async
?
email
.
deliver_later
:
email
.
deliver_now
end
end
...
...
ee/app/services/ee/users/destroy_service.rb
View file @
2616e2da
...
...
@@ -35,7 +35,8 @@ module EE
def
oncall_rotations_cleanup
(
user
)
::
IncidentManagement
::
OncallRotations
::
RemoveParticipantsService
.
new
(
user
.
oncall_rotations
,
user
user
,
false
).
execute
end
...
...
ee/app/services/incident_management/oncall_rotations/remove_participant_service.rb
View file @
2616e2da
...
...
@@ -6,9 +6,11 @@ module IncidentManagement
include
IncidentManagement
::
OncallRotations
::
SharedRotationLogic
# @param oncall_rotations [IncidentManagement::OncallRotation]
# @param user_to_remove [User]
def
initialize
(
oncall_rotation
,
user_to_remove
)
# @param async_email [Boolean]
def
initialize
(
oncall_rotation
,
user_to_remove
,
async_email
=
true
)
@oncall_rotation
=
oncall_rotation
@user_to_remove
=
user_to_remove
@async_email
=
async_email
end
def
execute
...
...
@@ -24,7 +26,7 @@ module IncidentManagement
private
attr_reader
:oncall_rotation
,
:user_to_remove
attr_reader
:oncall_rotation
,
:user_to_remove
,
:async_email
def
remove_user_from_rotation
participant
=
oncall_rotation
.
participants
.
for_user
(
user_to_remove
).
first
...
...
@@ -37,7 +39,7 @@ module IncidentManagement
end
def
send_notification
NotificationService
.
new
.
oncall_user_removed
(
oncall_rotation
,
user_to_remove
)
NotificationService
.
new
.
oncall_user_removed
(
oncall_rotation
,
user_to_remove
,
async_email
)
end
end
end
...
...
ee/app/services/incident_management/oncall_rotations/remove_participants_service.rb
View file @
2616e2da
...
...
@@ -5,16 +5,18 @@ module IncidentManagement
class
RemoveParticipantsService
# @param oncall_rotations [Array<IncidentManagement::OncallRotation>]
# @param user_to_remove [User]
def
initialize
(
oncall_rotations
,
user_to_remove
)
# @param async_email [Boolean]
def
initialize
(
oncall_rotations
,
user_to_remove
,
async_email
=
true
)
@oncall_rotations
=
oncall_rotations
@user_to_remove
=
user_to_remove
@async_email
=
async_email
end
attr_reader
:oncall_rotations
,
:user_to_remove
attr_reader
:oncall_rotations
,
:user_to_remove
,
:async_email
def
execute
oncall_rotations
.
each
do
|
oncall_rotation
|
RemoveParticipantService
.
new
(
oncall_rotation
,
user_to_remove
).
execute
RemoveParticipantService
.
new
(
oncall_rotation
,
user_to_remove
,
async_email
).
execute
end
end
end
...
...
ee/spec/services/ee/notification_service_spec.rb
View file @
2616e2da
...
...
@@ -934,6 +934,10 @@ RSpec.describe EE::NotificationService, :mailer do
subject
.
oncall_user_removed
(
rotation
,
user
)
end
it
'sends the email inline when async = false'
do
expect
{
subject
.
oncall_user_removed
(
rotation
,
user
,
false
)
}.
to
change
(
ActionMailer
::
Base
.
deliveries
,
:size
).
by
(
2
)
end
end
end
end
ee/spec/services/ee/users/destroy_service_spec.rb
View file @
2616e2da
...
...
@@ -46,6 +46,7 @@ RSpec.describe Users::DestroyService do
let
(
:schedule
)
{
create
(
:incident_management_oncall_schedule
,
project:
project
)
}
let
(
:rotation
)
{
create
(
:incident_management_oncall_rotation
,
schedule:
schedule
)
}
let!
(
:participant
)
{
create
(
:incident_management_oncall_participant
,
rotation:
rotation
,
user:
user
)
}
let!
(
:other_participant
)
{
create
(
:incident_management_oncall_participant
,
rotation:
rotation
)
}
context
'in their own project'
do
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
...
...
@@ -73,6 +74,10 @@ RSpec.describe Users::DestroyService do
expect
(
rotation
.
participants
.
reload
).
not_to
include
(
participant
)
end
it
'sends an email about the user being removed from the rotation'
do
expect
{
operation
}.
to
change
(
ActionMailer
::
Base
.
deliveries
,
:size
).
by
(
1
)
end
end
end
...
...
ee/spec/services/incident_management/oncall_rotations/remove_participants_service_spec.rb
View file @
2616e2da
...
...
@@ -20,12 +20,12 @@ RSpec.describe IncidentManagement::OncallRotations::RemoveParticipantsService do
expect
(
IncidentManagement
::
OncallRotations
::
RemoveParticipantService
)
.
to
receive
(
:new
)
.
with
(
rotation
,
user
)
.
with
(
rotation
,
user
,
true
)
.
and_return
(
remove_service
)
expect
(
IncidentManagement
::
OncallRotations
::
RemoveParticipantService
)
.
to
receive
(
:new
)
.
with
(
rotation_2
,
user
)
.
with
(
rotation_2
,
user
,
true
)
.
and_return
(
remove_service
)
expect
(
remove_service
).
to
receive
(
:execute
).
twice
...
...
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