summaryrefslogtreecommitdiff
path: root/spec/finders/group_descendants_finder_spec.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-01-20 14:35:48 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2018-01-22 17:02:04 +0100
commit26c4e47a0d0f860da3f00c37fa28d175bb17ccf1 (patch)
tree2f2fcf72bf8b249af55731c1c49628dbcce6902d /spec/finders/group_descendants_finder_spec.rb
parent2c3c5b35549185080296670cfe6710aa80f99944 (diff)
downloadgitlab-ce-26c4e47a0d0f860da3f00c37fa28d175bb17ccf1.tar.gz
Preload ancestors for subgroups matching filter
Otherwise we'd only preload the ancestors that would fit the page. That way, when a search result was on the first page, but the ancestor didn't fit the page anymore. We would not have the preloaded ancestor when rendering the hierarchy.
Diffstat (limited to 'spec/finders/group_descendants_finder_spec.rb')
-rw-r--r--spec/finders/group_descendants_finder_spec.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb
index 9cadd9a6000..375bcc9087e 100644
--- a/spec/finders/group_descendants_finder_spec.rb
+++ b/spec/finders/group_descendants_finder_spec.rb
@@ -73,7 +73,7 @@ describe GroupDescendantsFinder do
end
context 'with a filter' do
- let(:params) { { filter: 'tes' } }
+ let(:params) { { filter: 'test' } }
it 'includes only projects matching the filter' do
_other_project = create(:project, namespace: group)
@@ -198,6 +198,17 @@ describe GroupDescendantsFinder do
expect(finder.execute).to contain_exactly(subgroup, matching_project)
end
+ context 'with a small page size' do
+ let(:params) { { filter: 'test', per_page: 1 } }
+
+ it 'contains all the ancestors of a matching subgroup regardless the page size' do
+ subgroup = create(:group, :private, parent: group)
+ matching = create(:group, :private, name: 'testgroup', parent: subgroup)
+
+ expect(finder.execute).to contain_exactly(subgroup, matching)
+ end
+ end
+
it 'does not include the parent itself' do
group.update!(name: 'test')