BigW Consortium Gitlab

show_spec.rb 806 Bytes
Newer Older
1 2
require 'rails_helper'

3
describe 'Milestone show' do
4
  let(:user) { create(:user) }
5
  let(:project) { create(:project) }
6 7
  let(:milestone) { create(:milestone, project: project) }
  let(:labels) { create_list(:label, 2, project: project) }
8
  let(:issue_params) { { project: project, assignees: [user], author: user, milestone: milestone, labels: labels } }
9 10

  before do
11
    project.add_user(user, :developer)
12
    sign_in(user)
13 14 15
  end

  def visit_milestone
16
    visit project_milestone_path(project, milestone)
17 18 19 20 21 22 23 24 25 26
  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