diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 21:07:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 21:07:13 +0300 |
commit | d380b256b976811e54dc4eb7c9ba3ecc5a9ab5be (patch) | |
tree | 08e2636afd8c045961c04b05361ad4880c767aa2 /app/models/members | |
parent | d4aa95428e9ae63a476196bc8c1193d3de253530 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/member_role.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/members/member_role.rb b/app/models/members/member_role.rb index e9d7b1d3f80..36cbc97d049 100644 --- a/app/models/members/member_role.rb +++ b/app/models/members/member_role.rb @@ -11,6 +11,7 @@ class MemberRole < ApplicationRecord # rubocop:disable Gitlab/NamespacedClass validates :base_access_level, presence: true validate :belongs_to_top_level_namespace validate :validate_namespace_locked, on: :update + validate :attributes_locked_after_member_associated, on: :update validates_associated :members @@ -27,4 +28,11 @@ class MemberRole < ApplicationRecord # rubocop:disable Gitlab/NamespacedClass errors.add(:namespace, s_("MemberRole|can't be changed")) end + + def attributes_locked_after_member_associated + return unless members.present? + + errors.add(:base, s_("MemberRole|cannot be changed because it is already assigned to a user. "\ + "Please create a new Member Role instead")) + end end |