summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Miller <travis@travismiller.com>2017-08-28 19:02:52 -0500
committerTravis Miller <travis@travismiller.com>2017-08-29 08:31:36 -0500
commit2531fb3be9542c08231a6540a14b12d907b151e5 (patch)
tree8d14a225b5c4a0b09ff19406ee3332d89f4700e3
parent6782b406f77d237e58c23a3bce444e3cd4dde849 (diff)
downloadgitlab-ce-2531fb3be9542c08231a6540a14b12d907b151e5.tar.gz
Add missing N+1 test to issues spec
-rw-r--r--spec/requests/api/issues_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 7d120e4a234..03b1d14828d 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -509,6 +509,18 @@ describe API::Issues, :mailer do
describe "GET /projects/:id/issues" do
let(:base_url) { "/projects/#{project.id}" }
+ it 'avoids N+1 queries' do
+ control_count = ActiveRecord::QueryRecorder.new do
+ get api("/projects/#{project.id}/issues", user)
+ end.count
+
+ create(:issue, author: user, project: project)
+
+ expect do
+ get api("/projects/#{project.id}/issues", user)
+ end.not_to exceed_query_limit(control_count)
+ end
+
it 'returns 404 when project does not exist' do
get api('/projects/1000/issues', non_member)