Commit 9cdde576 authored by Stan Hu's avatar Stan Hu

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

parent 5aea8dc1
...@@ -30,6 +30,21 @@ describe API::Groups do ...@@ -30,6 +30,21 @@ describe API::Groups do
expect(json_response) expect(json_response)
.to satisfy_one { |group| group['name'] == group1.name } .to satisfy_one { |group| group['name'] == group1.name }
end 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 end
context "when authenticated as user" do context "when authenticated as user" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment