summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-19 13:11:09 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 22:49:41 +0200
commit22aa034427b9392b44d9ecba0a51bb1b6c6616d7 (patch)
tree674a46d4ea73af07ccc3b7f5dd56168d4c5c1997 /app/models
parentfb7a0f8c335631e1cb8c8f91e135e49528fad70e (diff)
downloadgitlab-ce-22aa034427b9392b44d9ecba0a51bb1b6c6616d7.tar.gz
Rename `GroupHierarchy` to `GroupDescendant`
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/group_descendant.rb (renamed from app/models/concerns/group_hierarchy.rb)24
-rw-r--r--app/models/group.rb2
-rw-r--r--app/models/project.rb6
3 files changed, 14 insertions, 18 deletions
diff --git a/app/models/concerns/group_hierarchy.rb b/app/models/concerns/group_descendant.rb
index 9e02a17f4c3..89a91f87a46 100644
--- a/app/models/concerns/group_hierarchy.rb
+++ b/app/models/concerns/group_descendant.rb
@@ -1,6 +1,6 @@
-module GroupHierarchy
+module GroupDescendant
def hierarchy(hierarchy_base = nil)
- tree_for_child(self, self, hierarchy_base)
+ expand_hierarchy_for_child(self, self, hierarchy_base)
end
def parent
@@ -11,29 +11,29 @@ module GroupHierarchy
end
end
- def tree_for_child(child, tree, hierarchy_base)
+ def expand_hierarchy_for_child(child, hierarchy, hierarchy_base)
if child.parent.nil? && hierarchy_base.present?
raise ArgumentError.new('specified base is not part of the tree')
end
if child.parent && child.parent != hierarchy_base
- tree_for_child(child.parent,
- { child.parent => tree },
- hierarchy_base)
+ expand_hierarchy_for_child(child.parent,
+ { child.parent => hierarchy },
+ hierarchy_base)
else
- tree
+ hierarchy
end
end
def merge_hierarchy(other_element, hierarchy_base = nil)
- GroupHierarchy.merge_hierarchies([self, other_element], hierarchy_base)
+ GroupDescendant.merge_hierarchies([self, other_element], hierarchy_base)
end
def self.merge_hierarchies(hierarchies, hierarchy_base = nil)
hierarchies = Array.wrap(hierarchies)
return if hierarchies.empty?
- unless hierarchies.all? { |hierarchy| hierarchy.is_a?(GroupHierarchy) }
+ unless hierarchies.all? { |hierarchy| hierarchy.is_a?(GroupDescendant) }
raise ArgumentError.new('element is not a hierarchy')
end
@@ -68,16 +68,16 @@ module GroupHierarchy
# we can check if its already in the hash. If so, we don't need to do anything
#
# Handled cases
- # [Hash, GroupHierarchy]
+ # [Hash, GroupDescendant]
elsif first_child.is_a?(Hash) && first_child.keys.include?(second_child)
first_child
elsif second_child.is_a?(Hash) && second_child.keys.include?(first_child)
second_child
- # If one or both elements are a GroupHierarchy, we wrap create an array
+ # If one or both elements are a GroupDescendant, we wrap create an array
# combining them.
#
# Handled cases:
- # [GroupHierarchy, Array], [GroupHierarchy, GroupHierarchy], [Array, Array]
+ # [GroupDescendant, Array], [GroupDescendant, GroupDescendant], [Array, Array]
else
Array.wrap(first_child) + Array.wrap(second_child)
end
diff --git a/app/models/group.rb b/app/models/group.rb
index 848e422e067..36439849086 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -6,7 +6,7 @@ class Group < Namespace
include Avatarable
include Referable
include SelectForProjectAuthorization
- include GroupHierarchy
+ include GroupDescendant
has_many :group_members, -> { where(requested_at: nil) }, dependent: :destroy, as: :source # rubocop:disable Cop/ActiveRecordDependent
alias_method :members, :group_members
diff --git a/app/models/project.rb b/app/models/project.rb
index c221055f8b4..bf883de48ed 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -17,7 +17,7 @@ class Project < ActiveRecord::Base
include ProjectFeaturesCompatibility
include SelectForProjectAuthorization
include Routable
- include GroupHierarchy
+ include GroupDescendant
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
@@ -1521,10 +1521,6 @@ class Project < ActiveRecord::Base
map.public_path_for_source_path(path)
end
- def parent
- namespace
- end
-
def parent_changed?
namespace_id_changed?
end