2016-12-20 09:48:04 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe 'Milestone show' do
|
2016-12-20 09:48:04 -05:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2016-12-20 09:48:04 -05:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
let(:labels) { create_list(:label, 2, project: project) }
|
2017-05-04 08:11:15 -04:00
|
|
|
let(:issue_params) { { project: project, assignees: [user], author: user, milestone: milestone, labels: labels } }
|
2016-12-20 09:48:04 -05:00
|
|
|
|
|
|
|
before do
|
2017-08-15 13:44:37 -04:00
|
|
|
project.add_user(user, :developer)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-12-20 09:48:04 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_milestone
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_milestone_path(project, milestone)
|
2016-12-20 09:48:04 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'avoids N+1 database queries' do
|
|
|
|
create(:labeled_issue, issue_params)
|
2017-09-14 11:46:28 -04:00
|
|
|
control = ActiveRecord::QueryRecorder.new { visit_milestone }
|
2016-12-20 09:48:04 -05:00
|
|
|
create_list(:labeled_issue, 10, issue_params)
|
|
|
|
|
2017-09-14 11:46:28 -04:00
|
|
|
expect { visit_milestone }.not_to exceed_query_limit(control)
|
2016-12-20 09:48:04 -05:00
|
|
|
end
|
|
|
|
end
|