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/namespaces/traversal/recursive.rb')
-rw-r--r--app/models/namespaces/traversal/recursive.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/namespaces/traversal/recursive.rb b/app/models/namespaces/traversal/recursive.rb
index c1ada715d6d..8d2c5d3be5a 100644
--- a/app/models/namespaces/traversal/recursive.rb
+++ b/app/models/namespaces/traversal/recursive.rb
@@ -7,12 +7,12 @@ module Namespaces
include RecursiveScopes
def root_ancestor
- return self if parent.nil?
-
- if persisted?
+ if persisted? && !parent_id.nil?
strong_memoize(:root_ancestor) do
- recursive_self_and_ancestors.reorder(nil).find_by(parent_id: nil)
+ recursive_ancestors.reorder(nil).find_by(parent_id: nil)
end
+ elsif parent.nil?
+ self
else
parent.root_ancestor
end