summaryrefslogtreecommitdiff
path: root/spec/controllers/groups
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-11-17 15:55:43 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2017-11-17 16:20:47 +0100
commit5a335c4d955bbb74a50ca30ac45d30f6ef66774d (patch)
tree490aae02c5cb2a2d1774c8b7094e9c7bc4c2c3a8 /spec/controllers/groups
parent4aa18590b3af27c9cb3cd3c2fc8c0a70e9a8758e (diff)
downloadgitlab-ce-5a335c4d955bbb74a50ca30ac45d30f6ef66774d.tar.gz
Remove the selects when counting the last page
The last page of the first collection is only loaded into memory when it is being viewed. If it isn't loaded into memory, the `#size` call triggers a count query. This `#count` would generate an invalid query if our custom preloaded counts are included by adding a separate `as count_column` alias on top of the count aliases. Removing the selects in this case will make sure a valid `COUNT(*)` is generated.
Diffstat (limited to 'spec/controllers/groups')
-rw-r--r--spec/controllers/groups/children_controller_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/controllers/groups/children_controller_spec.rb b/spec/controllers/groups/children_controller_spec.rb
index 4262d474e59..cb1b460fc0e 100644
--- a/spec/controllers/groups/children_controller_spec.rb
+++ b/spec/controllers/groups/children_controller_spec.rb
@@ -280,6 +280,17 @@ describe Groups::ChildrenController do
expect(assigns(:children)).to contain_exactly(other_subgroup, *next_page_projects.take(per_page - 1))
end
+
+ context 'with a mixed first page' do
+ let!(:first_page_subgroups) { [create(:group, :public, parent: group)] }
+ let!(:first_page_projects) { create_list(:project, per_page, :public, namespace: group) }
+
+ it 'correctly calculates the counts' do
+ get :index, group_id: group.to_param, sort: 'id_asc', page: 2, format: :json
+
+ expect(response).to have_gitlab_http_status(200)
+ end
+ end
end
end
end