diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2016-12-20 17:48:04 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2016-12-20 19:59:48 +0300 |
commit | 9c623e3e5d7434f2e30f7c389d13e5af4ede770a (patch) | |
tree | 03e905658ce5edeb8fb7d3b97be7e4ead5da835c /spec/features | |
parent | a2f57f23616bc1ab7547e5a7c517cdd49b172bd8 (diff) |
Added QueryRecorder to test N+1 fix on Milestone#show
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/milestones/show_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/features/milestones/show_spec.rb b/spec/features/milestones/show_spec.rb new file mode 100644 index 00000000000..40b4dc63697 --- /dev/null +++ b/spec/features/milestones/show_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +describe 'Milestone show', feature: true do + let(:user) { create(:user) } + let(:project) { create(:empty_project) } + let(:milestone) { create(:milestone, project: project) } + let(:labels) { create_list(:label, 2, project: project) } + let(:issue_params) { { project: project, assignee: user, author: user, milestone: milestone, labels: labels } } + + before do + project.add_user(user, :developer) + login_as(user) + end + + def visit_milestone + visit namespace_project_milestone_path(project.namespace, project, milestone) + end + + it 'avoids N+1 database queries' do + create(:labeled_issue, issue_params) + control_count = ActiveRecord::QueryRecorder.new { visit_milestone }.count + create_list(:labeled_issue, 10, issue_params) + + expect { visit_milestone }.not_to exceed_query_limit(control_count) + end +end |