Use update services to unassign users on membership deletion
What does this MR do and why?
Related to #431288 (closed)
When a user is removed from a project, there is an option to specify if the user should be also unassigned from issues and merge request. This option does unassign the user but does not create the corresponding unassignment event.
User is unassigned from the sidebar | User is unassigned through membership deletion |
---|---|
Demo | demo |
This MR updates Members::UnassignIssuablesService
to utilize the existing update services so that unassignment events are recorded.
MR acceptance checklist
How to set up and validate locally
- For convenience, make the following changes temporarily. This allows the worker to run synchronously.
--- a/app/services/members/destroy_service.rb
+++ b/app/services/members/destroy_service.rb
@@ -208,7 +208,7 @@ def enqueue_unassign_issuables(member)
source_type = member.is_a?(GroupMember) ? 'Group' : 'Project'
member.run_after_commit_or_now do
- MembersDestroyer::UnassignIssuablesWorker.perform_async(member.user_id, member.source_id, source_type)
+ MembersDestroyer::UnassignIssuablesWorker.new.perform(member.user_id, member.source_id, source_type)
end
end
end
-
Assign some user to an issue.
-
Remove the user's membership from the issue's project. Make sure to check
Also unassign this user from linked issues and merge requests
.
Check that the unassignment note is in the issue.
Demo:
Edited by euko