Enforce seat type restrictions on members for custom roles

What does this MR do and why?

Follow-up to !250549 (merged), part of https://gitlab.com/gitlab-org/gitlab/-/work_items/607620+.

Extends the seat type validation on Member to account for custom roles.

Enforcement looks at the existing MemberRole#occupies_seat attribute. A custom role that does not occupy a seat is treated as its base access level, so for instance on Ultimate a custom role built from Guest base access level + read_code ability stays permitted by a free seat.

The validation now also runs when a member's custom role changes (member_role_id_changed?). A member's access level doesn't change when a custom role is attached, so checking only access_level_changed? would let it through.

The feature is gated behind the seat_assignment_model feature flag, which is default off.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

Green pipeline 🟢

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.

Related to #607620

Edited by Katherine Richards

Merge request reports

Loading
Loading