diff options
author | Rémy Coutable <remy@rymai.me> | 2018-02-05 10:11:41 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-02-05 10:11:41 +0000 |
commit | aea3569b4f39d98de87a93b7bf0c64e42cbcfeb0 (patch) | |
tree | 62463040c6440e14491e05275f0c9d0f57e06d81 | |
parent | 679245e56ae1bee1054b785b9c7c8db2090a2c2a (diff) | |
parent | 9cdde576873fc601ad0f320a692105e992e9b69f (diff) | |
download | gitlab-ce-aea3569b4f39d98de87a93b7bf0c64e42cbcfeb0.tar.gz |
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
-rw-r--r-- | spec/requests/api/groups_spec.rb | 15 |
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 |