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:
authorMichael Kozono <mkozono@gmail.com>2017-09-02 02:49:09 +0300
committerMichael Kozono <mkozono@gmail.com>2017-09-06 22:07:20 +0300
commit1cc7f4a45d9e9fdf1943eb92d3cd2071ba497337 (patch)
treecdaebcf4f86d442a00a45d7a6bab4584a7b48dbd /app/models/namespace.rb
parent8437a24ff46220e2813ce3d82a52062dd259276b (diff)
Enable share_with_group_lock on subgroup
…when needed
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index e7cbc5170e8..aeda829415a 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -44,6 +44,10 @@ class Namespace < ActiveRecord::Base
after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') }
+ before_create :sync_share_with_group_lock_with_parent
+ before_update :sync_share_with_group_lock_with_parent, if: :parent_changed?
+ after_commit :force_share_with_group_lock_on_descendants, on: :update, if: -> { previous_changes.key?('share_with_group_lock') && share_with_group_lock? }
+
# Legacy Storage specific hooks
after_update :move_dir, if: :path_changed?
@@ -219,4 +223,14 @@ class Namespace < ActiveRecord::Base
errors.add(:parent_id, "has too deep level of nesting")
end
end
+
+ def sync_share_with_group_lock_with_parent
+ if has_parent? && parent.share_with_group_lock?
+ self.share_with_group_lock = true
+ end
+ end
+
+ def force_share_with_group_lock_on_descendants
+ descendants.update_all(share_with_group_lock: true)
+ end
end