diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-10 21:08:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-10 21:08:54 +0300 |
commit | c596046be917b250019fdfb509be85cfb48df152 (patch) | |
tree | 2c3716f6f70b42e0683022269a13117704d85d15 /app/models/members | |
parent | 9afe9ca576408a1145b6250d9493032fe65255ae (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/group_member.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index 8c224dea88f..34958936c9f 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -13,6 +13,9 @@ 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 + default_scope { where(source_type: SOURCE_TYPE) } # rubocop:disable Cop/DefaultScope scope :of_groups, ->(groups) { where(source_id: groups.select(:id)) } @@ -45,6 +48,12 @@ class GroupMember < Member private + 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) } |