summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorBryce Johnson <bryce@gitlab.com>2017-09-07 14:46:23 -0400
committerBryce Johnson <bryce@gitlab.com>2017-09-07 14:46:23 -0400
commit3d9b6bc2b98583a5220870025e942077c9303eaf (patch)
treec938afc9a0e169ab8ff0b6b55b96c2a5b365efee /app/models/namespace.rb
parente4348ae8c221a63d0e2c4e428fcae8c3bca0eb2f (diff)
parentbc955cfc8e75e17897ab25717176209fefbba915 (diff)
downloadgitlab-ce-backport-issues-controller-changes.tar.gz
Merge branch 'master' into backport-issues-controller-changesbackport-issues-controller-changes
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..4a9a23fea1f 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_update :force_share_with_group_lock_on_descendants, if: -> { share_with_group_lock_changed? && 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 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