Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 903d0154969..1eaa4499eb5 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -48,6 +48,7 @@ class Group < Namespace
has_many :labels, class_name: 'GroupLabel'
has_many :variables, class_name: 'Ci::GroupVariable'
+ has_many :daily_build_group_report_results, class_name: 'Ci::DailyBuildGroupReportResult'
has_many :custom_attributes, class_name: 'GroupCustomAttribute'
has_many :boards
@@ -75,7 +76,7 @@ class Group < Namespace
has_many :dependency_proxy_blobs, class_name: 'DependencyProxy::Blob'
has_many :dependency_proxy_manifests, class_name: 'DependencyProxy::Manifest'
- # debian_distributions must be destroyed by ruby code in order to properly remove carrierwave uploads
+ # debian_distributions and associated component_files must be destroyed by ruby code in order to properly remove carrierwave uploads
has_many :debian_distributions, class_name: 'Packages::Debian::GroupDistribution', dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
accepts_nested_attributes_for :variables, allow_destroy: true
@@ -84,7 +85,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 +170,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)