diff options
author | Sean McGivern <sean@gitlab.com> | 2017-11-22 11:12:47 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-11-22 15:08:55 +0000 |
commit | db1925f917b30571e0e9d4de63417db90dc693d7 (patch) | |
tree | 82cfe66b4c93e7c1127d2782f81b0c97d5e3e60e /spec/requests | |
parent | 0efa7e24f22abd1dc04c165f31e7b77b0eb30ed4 (diff) | |
download | gitlab-ce-db1925f917b30571e0e9d4de63417db90dc693d7.tar.gz |
Improve output for extra queries in specsimprove-extra-queries-output
Previously, this used `Array#-`, which would remove all queries that matches the
query text in the original set.
However, sometimes we have a problem with parameterised queries, where the query
text is identical both times, so we'd run a query N times instead of once, and
it would be hidden from the output.
Replace the logic to only remove a given query N times from the actual log,
where N is the number of times it appears in the expected log.
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 35c6b3bb2fb..91616da6d9a 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -172,15 +172,15 @@ describe API::MergeRequests do context "when authenticated" do it 'avoids N+1 queries' do - control_count = ActiveRecord::QueryRecorder.new do + control = ActiveRecord::QueryRecorder.new do get api("/projects/#{project.id}/merge_requests", user) - end.count + end create(:merge_request, state: 'closed', milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: "Test", created_at: base_time) expect do get api("/projects/#{project.id}/merge_requests", user) - end.not_to exceed_query_limit(control_count) + end.not_to exceed_query_limit(control) end it "returns an array of all merge_requests" do |