diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-05 11:16:08 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-06 14:09:36 +0200 |
commit | de35c044fb5a2def205d9da84e2792c97f40d481 (patch) | |
tree | eb4dfdf1e27b70238915302ae2cb4ad2961aca49 /spec/controllers/concerns/group_tree_spec.rb | |
parent | 34fe32740f475051dfcbb696f11c270ae327dc4a (diff) | |
download | gitlab-ce-de35c044fb5a2def205d9da84e2792c97f40d481.tar.gz |
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.rb | 11 |
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 |