summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-02-03 15:38:19 -0800
committerStan Hu <stanhu@gmail.com>2018-02-03 15:38:19 -0800
commit9cdde576873fc601ad0f320a692105e992e9b69f (patch)
tree29acde48064deb84a48d8c0d6fb45ed24daac5fc /spec/requests
parent5aea8dc1a6dc17d4a73e65f3c3a0f8b7e29686eb (diff)
downloadgitlab-ce-9cdde576873fc601ad0f320a692105e992e9b69f.tar.gz
Backport /api/v4/groups N+1 query check from EEsh-backport-groups-api-optimization
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/groups_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 3c0b4728dc2..bb0034e3237 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -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