Merge branch 'sh-backport-groups-api-optimization' into 'master'

Backport /api/v4/groups N+1 query check from EE

See merge request gitlab-org/gitlab-ce!16913
This commit is contained in:
Rémy Coutable 2018-02-05 10:11:41 +00:00
commit aea3569b4f

View file

@ -30,6 +30,21 @@ describe API::Groups do
expect(json_response)
.to satisfy_one { |group| group['name'] == group1.name }
end
it 'avoids N+1 queries' do
# Establish baseline
get api("/groups", admin)
control = ActiveRecord::QueryRecorder.new do
get api("/groups", admin)
end
create(:group)
expect do
get api("/groups", admin)
end.not_to exceed_query_limit(control)
end
end
context "when authenticated as user" do