Update a user's user_group_member_roles when group membership is updated

What does this MR do and why?

Update a user's user_group_member_roles when either member_role_id or access_level value of their group membership is updated.

References

Implements part of Create user_group_member_roles when group membe... (#515215 - closed).

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Start GDK in SAAS mode
    $ GITLAB_SIMULATE_SAAS=1 gdk start
  2. Enable feature flag
    $ rails c
    > Feature.enable(:cache_user_group_member_roles)
  3. Login with root, go to a group that root owns (e.g. http://localhost:9393/groups/flightjs), then create two new member roles in http://localhost:9393/groups/flightjs/-/settings/roles_and_permissions page
  4. Add a new member to the group and assign them the first member role
  5. In Rails console, verify that a new Authz::UserGroupMemberRole is created for the invited user
    $ rails c
    > Authz::UserGroupMemberRole.last
    => #<Authz::UserGroupMemberRole
      ...     
      member_role_id: <id_of_first_member_role>,
      >
  6. Update the membership of the user: change the member role to the other member role
  7. In Rails console, verify that the Authz::UserGroupMemberRole record of the user is updated: member_role_id is now that of the second member role
    $ rails c
    > Authz::UserGroupMemberRole.last
    => #<Authz::UserGroupMemberRole
      ...     
      member_role_id: <id_of_second_member_role>,
      >

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugie Limpin

Merge request reports

Loading