diff options
author | Alexander Koval <al3xander.koval@gmail.com> | 2019-02-27 13:28:53 +0300 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-02-27 13:28:53 +0300 |
commit | 1874aa9a3b3151ece76030d620017425e3cafc2f (patch) | |
tree | 3802218f22d4d93a721339d5cd7fcd1e18d8baf5 /spec/requests/api/merge_requests_spec.rb | |
parent | d2336e026903f9ff81362fba034c02d95ac3fe81 (diff) |
Reduce code duplication
Move logic of obtaining Issuable data to separate method
Diffstat (limited to 'spec/requests/api/merge_requests_spec.rb')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index db56739af2f..8aba0bc8e18 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -320,6 +320,18 @@ describe API::MergeRequests do expect(json_response.first['title']).to eq merge_request_closed.title expect(json_response.first['id']).to eq merge_request_closed.id end + + it 'avoids N+1 queries' do + control = ActiveRecord::QueryRecorder.new do + get api("/projects/#{project.id}/merge_requests", user) + end.count + + create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, created_at: base_time) + + expect do + get api("/projects/#{project.id}/merge_requests", user) + end.not_to exceed_query_limit(control) + end end describe "GET /groups/:id/merge_requests" do |