Commit 0a9a33e7 authored by Stan Hu's avatar Stan Hu

Add spec for N+1 queries

parent 88c4248a
......@@ -36,6 +36,18 @@ describe API::MergeRequests do
end
context "when authenticated" do
it 'avoids N+1 queries' do
control_count = ActiveRecord::QueryRecorder.new do
get api("/projects/#{project.id}/merge_requests", user)
end.count
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
it "returns an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests", user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment