summaryrefslogtreecommitdiff
path: root/app/models/group.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-05 16:20:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-05 16:20:45 +0000
commitd298fad0c0564454271cba11e6f20c19681534ac (patch)
tree0a19d07d8b3bdd2574617305c300e404f2ace581 /app/models/group.rb
parentc9f9eec79cab801a50db698f682aacffbedf07f7 (diff)
downloadgitlab-ce-13.9.0-rc41.tar.gz
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc41
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 903d0154969..aa79d379fac 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -84,7 +84,7 @@ class Group < Namespace
validate :visibility_level_allowed_by_sub_groups
validate :visibility_level_allowed_by_parent
validate :two_factor_authentication_allowed
- validates :variables, variable_duplicates: true
+ validates :variables, nested_attributes_duplicates: true
validates :two_factor_grace_period, presence: true, numericality: { greater_than_or_equal_to: 0 }
@@ -169,6 +169,15 @@ class Group < Namespace
where('NOT EXISTS (?)', services)
end
+ # This method can be used only if all groups have the same top-level
+ # group
+ def preset_root_ancestor_for(groups)
+ return groups if groups.size < 2
+
+ root = groups.first.root_ancestor
+ groups.drop(1).each { |group| group.root_ancestor = root }
+ end
+
private
def public_to_user_arel(user)