Skip to content

Leave unassignment notes for removed member

euko requested to merge 431288-unassign-users-on-membership-deletion into master

What does this MR do and why?

Related to #431288 (closed)

When a user is removed from a project or group, there is an option to specify if the user should be also unassigned from issues and merge request.

When the option was used, the unassignments were not recorded previously.

This MR updates Members::UnassignIssuablesService to utilize the existing update services to handle issue/MR unassignments to fix the issue.

For de-risking, a feature flag is added to control the deployment.

The following demos demonstrate the bug.

User is unassigned from the sidebar (unassignment note is created) User is unassigned through membership deletion (unassigment note is not created)
Demo demo

MR acceptance checklist

How to set up and validate locally

  1. Enable the feature flag new_unassignment_service
Feature.enable(:new_unassignment_service)
  1. 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
@@ -209,7 +209,7 @@ def enqueue_unassign_issuables(member)
       current_user_id = current_user.id
 
       member.run_after_commit_or_now do
-        MembersDestroyer::UnassignIssuablesWorker.perform_async(
+        MembersDestroyer::UnassignIssuablesWorker.new.perform(
           member.user_id,
           member.source_id,
           source_type,
  1. Pick some user and add it to a project/group. Then assign the user to an issue.

  2. Remove the user's membership from the issue's project. Make sure to check Also unassign this user from linked issues and merge requests.

Confirm that the unassignment note is created.

Demo

Edited by euko

Merge request reports

Loading