diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-23 21:07:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-23 21:07:55 +0300 |
commit | 5421d61b1d5ffe11a9c7afbe2259b4e4d0e7c993 (patch) | |
tree | 093cfd5a5f80119f6e9c7ccd2c646ca2482cc3d2 /app/models/members | |
parent | bc0f141f2f073a971aad1eb5349bb718747df028 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/member_role.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/members/member_role.rb b/app/models/members/member_role.rb index b4e3d6874ef..0661082dced 100644 --- a/app/models/members/member_role.rb +++ b/app/models/members/member_role.rb @@ -7,12 +7,21 @@ class MemberRole < ApplicationRecord # rubocop:disable Gitlab/NamespacedClass validates :namespace, presence: true validates :base_access_level, presence: true validate :belongs_to_top_level_namespace + validate :validate_namespace_locked, on: :update + + validates_associated :members private def belongs_to_top_level_namespace return if !namespace || namespace.root? - errors.add(:namespace, s_("must be top-level namespace")) + errors.add(:namespace, s_("MemberRole|must be top-level namespace")) + end + + def validate_namespace_locked + return unless namespace_id_changed? + + errors.add(:namespace, s_("MemberRole|can't be changed")) end end |