Commit 68f90013 authored by Jarka Košanová's avatar Jarka Košanová

Rename GroupHierarchy into ObjectHierarchy

- we now use the hierarchy class also for epics
- also rename supports_nested_groups? into supports_nested_objects?
  - move it to a concern
- add checks for epics
parent 9b5b41b9
......@@ -4,6 +4,7 @@ class Groups::EpicLinksController < Groups::EpicsController
include EpicRelations
before_action :check_feature_flag!
before_action :check_nested_support!
before_action do
push_frontend_feature_flag(:epic_links)
......@@ -32,4 +33,8 @@ class Groups::EpicLinksController < Groups::EpicsController
def check_feature_flag!
render_404 unless Feature.enabled?(:epic_links, group)
end
def check_nested_support!
render_404 unless Epic.supports_nested_objects?
end
end
......@@ -108,10 +108,10 @@ module Geo
def group_uploads
namespace_ids =
if current_node.selective_sync_by_namespaces?
Gitlab::GroupHierarchy.new(current_node.namespaces).base_and_descendants.select(:id)
Gitlab::ObjectHierarchy.new(current_node.namespaces).base_and_descendants.select(:id)
elsif current_node.selective_sync_by_shards?
leaf_groups = Namespace.where(id: current_node.projects.select(:namespace_id))
Gitlab::GroupHierarchy.new(leaf_groups).base_and_ancestors.select(:id)
Gitlab::ObjectHierarchy.new(leaf_groups).base_and_ancestors.select(:id)
else
Namespace.none
end
......
......@@ -21,6 +21,7 @@ module EE
if parent.is_a?(Group)
data[:issueLinksEndpoint] = group_epic_issues_path(parent, issuable)
data[:epicLinksEndpoint] = group_epic_links_path(parent, issuable)
data[:subepicsSupported] = ::Epic.supports_nested_objects?
end
data
......
......@@ -12,6 +12,7 @@ module EE
include Referable
include Awardable
include LabelEventable
include Descendant
enum state: { opened: 1, closed: 2 }
......@@ -228,8 +229,7 @@ module EE
end
def hierarchy
::Gitlab::GroupHierarchy
.new(self.class.where(id: id))
::Gitlab::ObjectHierarchy.new(self.class.where(id: id))
end
# we don't support project epics for epics yet, planned in the future #4019
......
......@@ -186,7 +186,7 @@ module EE
project_creation_levels << nil
end
developer_groups_hierarchy = ::Gitlab::GroupHierarchy.new(developer_groups).base_and_descendants
developer_groups_hierarchy = ::Gitlab::ObjectHierarchy.new(developer_groups).base_and_descendants
::Group.where(id: developer_groups_hierarchy.select(:id),
project_creation_level: project_creation_levels)
end
......
......@@ -187,7 +187,7 @@ class GeoNode < ActiveRecord::Base
return Project.all unless selective_sync?
if selective_sync_by_namespaces?
query = Gitlab::GroupHierarchy.new(namespaces).base_and_descendants
query = Gitlab::ObjectHierarchy.new(namespaces).base_and_descendants
Project.where(namespace_id: query.select(:id))
elsif selective_sync_by_shards?
Project.where(repository_storage: selective_sync_shards)
......
......@@ -52,7 +52,7 @@ module EE
namespaces = ::Namespace.reorder(nil).where('namespaces.id = projects.namespace_id')
if ::Feature.enabled?(:shared_runner_minutes_on_root_namespace)
namespaces = ::Gitlab::GroupHierarchy.new(namespaces).roots
namespaces = ::Gitlab::ObjectHierarchy.new(namespaces).roots
end
namespaces
......
......@@ -58,7 +58,7 @@ module Gitlab
# Returns an ActiveRecord::Relation that includes the given groups, and all
# their (recursive) ancestors.
def groups_and_ancestors_for(groups)
Gitlab::GroupHierarchy
Gitlab::ObjectHierarchy
.new(groups)
.base_and_ancestors
.select(:id, :parent_id, :plan_id)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Groups::EpicLinksController do
describe Groups::EpicLinksController, :postgresql do
let(:group) { create(:group, :public) }
let(:parent_epic) { create(:epic, group: group) }
let(:epic1) { create(:epic, group: group) }
......
......@@ -188,7 +188,7 @@ describe Namespace do
end
end
if Group.supports_nested_groups?
if Group.supports_nested_objects?
context 'when license is applied to parent group' do
let(:child_group) { create :group, parent: group }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe EpicLinks::CreateService, :nested_groups do
describe EpicLinks::CreateService, :postgresql do
describe '#execute' do
let(:group) { create(:group) }
let(:user) { create(:user) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe EpicLinks::ListService do
describe EpicLinks::ListService, :postgresql do
let(:user) { create :user }
let(:group) { create(:group, :public) }
let(:parent_epic) { create(:epic, group: group) }
......@@ -51,7 +51,7 @@ describe EpicLinks::ListService do
end
end
context 'with nested groups', :nested_groups do
context 'with nested groups' do
let(:subgroup1) { create(:group, :private, parent: group) }
let(:subgroup2) { create(:group, :private, parent: group) }
let!(:epic_subgroup1) { create :epic, group: subgroup1, parent: parent_epic }
......
......@@ -45,7 +45,7 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
# Returns a relation that includes the ancestors_base set of groups
# Returns a relation that includes the ancestors_base set of objects
# and all their ancestors (recursively).
#
# Passing an `upto` will stop the recursion once the specified parent_id is
......
......@@ -220,7 +220,8 @@ describe IssuablesHelper do
initialTitleText: epic.title,
initialDescriptionHtml: '<p dir="auto">epic text</p>',
initialDescriptionText: 'epic text',
initialTaskStatus: '0 of 0 tasks completed'
initialTaskStatus: '0 of 0 tasks completed',
subepicsSupported: Gitlab::Database.postgresql? ? true : false
}
expect(helper.issuable_initial_data(epic)).to eq(expected_data)
end
......
......@@ -119,7 +119,7 @@ describe Gitlab::ObjectHierarchy, :postgresql do
end
end
describe '#all_groups' do
describe '#all_objects' do
let(:relation) do
described_class.new(Group.where(id: child1.id)).all_objects
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment