diff options
author | Stan Hu <stanhu@gmail.com> | 2018-02-03 15:38:19 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-02-03 15:38:19 -0800 |
commit | 9cdde576873fc601ad0f320a692105e992e9b69f (patch) | |
tree | 29acde48064deb84a48d8c0d6fb45ed24daac5fc | |
parent | 5aea8dc1a6dc17d4a73e65f3c3a0f8b7e29686eb (diff) | |
download | gitlab-ce-sh-backport-groups-api-optimization.tar.gz |
Backport /api/v4/groups N+1 query check from EEsh-backport-groups-api-optimization
-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 |