Commit 9c300fd9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Use the new query-recorder features as a PoC

parent 6dbd21ab
...@@ -18,9 +18,9 @@ describe 'Milestone show' do ...@@ -18,9 +18,9 @@ describe 'Milestone show' do
it 'avoids N+1 database queries' do it 'avoids N+1 database queries' do
create(:labeled_issue, issue_params) create(:labeled_issue, issue_params)
control_count = ActiveRecord::QueryRecorder.new { visit_milestone }.count control = ActiveRecord::QueryRecorder.new { visit_milestone }
create_list(:labeled_issue, 10, issue_params) create_list(:labeled_issue, 10, issue_params)
expect { visit_milestone }.not_to exceed_query_limit(control_count) expect { visit_milestone }.not_to exceed_query_limit(control)
end end
end end
...@@ -54,9 +54,9 @@ describe API::Projects do ...@@ -54,9 +54,9 @@ describe API::Projects do
shared_examples_for 'projects response without N + 1 queries' do shared_examples_for 'projects response without N + 1 queries' do
it 'avoids N + 1 queries' do it 'avoids N + 1 queries' do
control_count = ActiveRecord::QueryRecorder.new do control = ActiveRecord::QueryRecorder.new do
get api('/projects', current_user) get api('/projects', current_user)
end.count end
if defined?(additional_project) if defined?(additional_project)
additional_project additional_project
...@@ -66,7 +66,7 @@ describe API::Projects do ...@@ -66,7 +66,7 @@ describe API::Projects do
expect do expect do
get api('/projects', current_user) get api('/projects', current_user)
end.not_to exceed_query_limit(control_count + 8) end.not_to exceed_query_limit(control).with_threshold(8)
end end
end end
......
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