summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-10-05 10:32:52 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-05 11:11:21 +0200
commit951abe2b2efc3a208ceea46d9c1c47d3d253ff63 (patch)
treebeb57ac3312f4c0c45285ce82d7849220e5a7cdc /spec
parentec8a7a36c09f44c44a21444f632389e7d08166cf (diff)
downloadgitlab-ce-951abe2b2efc3a208ceea46d9c1c47d3d253ff63.tar.gz
Load counts everywhere we render a group tree
Diffstat (limited to 'spec')
-rw-r--r--spec/finders/group_descendants_finder_spec.rb12
-rw-r--r--spec/models/concerns/loaded_in_group_list_spec.rb28
2 files changed, 28 insertions, 12 deletions
diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb
index 7b9dfcbfad0..86a7a793457 100644
--- a/spec/finders/group_descendants_finder_spec.rb
+++ b/spec/finders/group_descendants_finder_spec.rb
@@ -46,18 +46,6 @@ describe GroupDescendantsFinder do
expect(finder.execute).to contain_exactly(subgroup, project)
end
- it 'includes the preloaded counts for groups' do
- create(:group, parent: subgroup)
- create(:project, namespace: subgroup)
- subgroup.add_developer(create(:user))
-
- found_group = finder.execute.detect { |child| child.is_a?(Group) }
-
- expect(found_group.preloaded_project_count).to eq(1)
- expect(found_group.preloaded_subgroup_count).to eq(1)
- expect(found_group.preloaded_member_count).to eq(1)
- end
-
it 'does not include subgroups the user does not have access to' do
subgroup.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
diff --git a/spec/models/concerns/loaded_in_group_list_spec.rb b/spec/models/concerns/loaded_in_group_list_spec.rb
new file mode 100644
index 00000000000..d64b288aa0c
--- /dev/null
+++ b/spec/models/concerns/loaded_in_group_list_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe LoadedInGroupList do
+ let(:parent) { create(:group) }
+ subject(:found_group) { Group.with_selects_for_list.find_by(id: parent.id) }
+
+ before do
+ create(:group, parent: parent)
+ create(:project, namespace: parent)
+ parent.add_developer(create(:user))
+ end
+
+ describe '.with_selects_for_list' do
+ it 'includes the preloaded counts for groups' do
+ found_group = Group.with_selects_for_list.find_by(id: parent.id)
+
+ expect(found_group.preloaded_project_count).to eq(1)
+ expect(found_group.preloaded_subgroup_count).to eq(1)
+ expect(found_group.preloaded_member_count).to eq(1)
+ end
+ end
+
+ describe '#children_count' do
+ it 'counts groups and projects' do
+ expect(found_group.children_count).to eq(2)
+ end
+ end
+end