diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-08 15:13:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-08 15:13:04 +0300 |
commit | 886ecba0bd2d964504b43303a39cfa2386f0feed (patch) | |
tree | e814b9f24f3df16bc1a8c8725a168fac3844d719 /app/models/members | |
parent | cb09086128f2923126d009a88b478ff3919c8309 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/group_member.rb | 11 | ||||
-rw-r--r-- | app/models/members/project_member.rb | 11 |
2 files changed, 11 insertions, 11 deletions
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index 9062a405218..1ad4cb6d368 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -6,6 +6,7 @@ class GroupMember < Member include CreatedAtFilterable SOURCE_TYPE = 'Namespace' + SOURCE_TYPE_FORMAT = /\ANamespace\z/.freeze belongs_to :group, foreign_key: 'source_id' alias_attribute :namespace_id, :source_id @@ -13,9 +14,7 @@ class GroupMember < Member # Make sure group member points only to group as it source default_value_for :source_type, SOURCE_TYPE - validates :source_type, format: { with: /\ANamespace\z/ } - validates :access_level, presence: true - validate :access_level_inclusion + validates :source_type, format: { with: SOURCE_TYPE_FORMAT } default_scope { where(source_type: SOURCE_TYPE) } # rubocop:disable Cop/DefaultScope @@ -65,12 +64,6 @@ class GroupMember < Member super end - def access_level_inclusion - return if access_level.in?(Gitlab::Access.all_values) - - errors.add(:access_level, "is not included in the list") - end - def send_invite run_after_commit_or_now { notification_service.invite_group_member(self, @raw_invite_token) } diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index 89b72508e84..6fc665cb87a 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -3,6 +3,7 @@ class ProjectMember < Member extend ::Gitlab::Utils::Override SOURCE_TYPE = 'Project' + SOURCE_TYPE_FORMAT = /\AProject\z/.freeze belongs_to :project, foreign_key: 'source_id' @@ -10,8 +11,7 @@ class ProjectMember < Member # Make sure project member points only to project as it source default_value_for :source_type, SOURCE_TYPE - validates :source_type, format: { with: /\AProject\z/ } - validates :access_level, inclusion: { in: Gitlab::Access.values } + validates :source_type, format: { with: SOURCE_TYPE_FORMAT } default_scope { where(source_type: SOURCE_TYPE) } # rubocop:disable Cop/DefaultScope scope :in_project, ->(project) { where(source_id: project.id) } @@ -92,6 +92,13 @@ class ProjectMember < Member private + override :access_level_inclusion + def access_level_inclusion + return if access_level.in?(Gitlab::Access.values) + + errors.add(:access_level, "is not included in the list") + end + override :refresh_member_authorized_projects def refresh_member_authorized_projects(blocking:) return unless user |