From 5c2078838bb9de710f9025513c4b6ec664bba313 Mon Sep 17 00:00:00 2001 From: Mario de la Ossa Date: Thu, 26 Apr 2018 13:53:13 -0600 Subject: Backport of 4084-epics-username-autocomplete --- app/models/namespace.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/models/namespace.rb') diff --git a/app/models/namespace.rb b/app/models/namespace.rb index c29a53e5ce7..637bcbc7a09 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -163,6 +163,13 @@ class Namespace < ActiveRecord::Base projects.with_shared_runners.any? end + # Returns all ancestors, self, and descendants of the current namespace. + def self_and_hierarchy + Gitlab::GroupHierarchy + .new(self.class.where(id: id)) + .all_groups + end + # Returns all the ancestors of the current namespaces. def ancestors return self.class.none unless parent_id -- cgit v1.2.1