Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-07-05 12:16:08 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-07-06 15:09:36 +0300
commitde35c044fb5a2def205d9da84e2792c97f40d481 (patch)
treeeb4dfdf1e27b70238915302ae2cb4ad2961aca49 /spec/controllers/concerns/group_tree_spec.rb
parent34fe32740f475051dfcbb696f11c270ae327dc4a (diff)
Preload ancestors after pagination when filtering
We need to preload the ancestors of search results after applying pagination limits. This way the search results itself are paginated, but not the ancestors. If we don't do this, we might not preload a parent group of a search result as it has been cut off by pagination.
Diffstat (limited to 'spec/controllers/concerns/group_tree_spec.rb')
-rw-r--r--spec/controllers/concerns/group_tree_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/controllers/concerns/group_tree_spec.rb b/spec/controllers/concerns/group_tree_spec.rb
index ba84fbf8564..503eb416962 100644
--- a/spec/controllers/concerns/group_tree_spec.rb
+++ b/spec/controllers/concerns/group_tree_spec.rb
@@ -63,6 +63,17 @@ describe GroupTree do
expect(assigns(:groups)).to contain_exactly(parent, subgroup)
end
+
+ it 'preloads parents regardless of pagination' do
+ allow(Kaminari.config).to receive(:default_per_page).and_return(1)
+ group = create(:group, :public)
+ subgroup = create(:group, :public, parent: group)
+ search_result = create(:group, :public, name: 'result', parent: subgroup)
+
+ get :index, filter: 'resu', format: :json
+
+ expect(assigns(:groups)).to contain_exactly(group, subgroup, search_result)
+ end
end
context 'json content' do