Remove custom admin roles assignments if user is an admin

What does this MR do and why?

Update Users::MemberRoles::AssignService to remove a user's user_member_roles records if they are admin. Admins already have all the ability custom admin roles can grant so existing assignments are unnecessary.

References

Implements Update Users::MemberRoles::AssignService to rem... (#535965 - closed). Part of Add ability to assign custom role in user settings (#501553 - closed).

Screenshots or screen recordings

Screen_Recording_2025-04-15_at_4.34.05_PM

How to set up and validate locally

  1. Enable admin custom roles feature flag

    $ rails c
    > Feature.enable(:custom_admin_roles)
  2. Login with an admin user (e.g. root)

  3. Create a custom admin role

    Create custom admin role Screen_Recording_2025-04-07_at_3.56.16_PM
  4. Go to /admin/users page and create a new user (type: Auditor) with one of the custom admin role you created

  5. On the new user show page click on Edit and verify that the custom admin role you selected during creation is correctly displayed

  6. Change the user's type to Admin and click Save changes

  7. Click on Edit again and verify that the custom admin role has been removed

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