diff options
author | Rémy Coutable <remy@rymai.me> | 2018-01-31 11:35:56 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-31 11:35:56 +0000 |
commit | 08e013431acb5238b4806260c4b9c304837097a3 (patch) | |
tree | d2a4c7a11a3b54c08226cd4ccdfa30147f8d9ef0 /spec | |
parent | 5d8bb33d48826abc7cd348a7c151c5b6985f0ade (diff) | |
parent | 46a6edc7314ce8acab5d8ce04799bd3557bc26bc (diff) | |
download | gitlab-ce-08e013431acb5238b4806260c4b9c304837097a3.tar.gz |
Merge branch 'sh-fix-project-members-api-perf' into 'master'
Remove N+1 queries with /projects/:project_id/{access_requests,members} API endpoints
See merge request gitlab-org/gitlab-ce!16751
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/members_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index 73bd4785b11..ec500838eb2 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -44,6 +44,21 @@ describe API::Members do end end + it 'avoids N+1 queries' do + # Establish baseline + get api("/#{source_type.pluralize}/#{source.id}/members", master) + + control = ActiveRecord::QueryRecorder.new do + get api("/#{source_type.pluralize}/#{source.id}/members", master) + end + + project.add_developer(create(:user)) + + expect do + get api("/#{source_type.pluralize}/#{source.id}/members", master) + end.not_to exceed_query_limit(control) + end + it 'does not return invitees' do create(:"#{source_type}_member", invite_token: '123', invite_email: 'test@abc.com', source: source, user: nil) |