debian-mirror-gitlab/spec/features/milestones/user_views_milestone_spec.rb

34 lines
824 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2018-10-15 14:42:47 +05:30
describe "User views milestone" do
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:milestone) { create(:milestone, project: project) }
set(:labels) { create_list(:label, 2, project: project) }
before do
project.add_developer(user)
sign_in(user)
end
it "avoids N+1 database queries" do
ISSUE_PARAMS = { project: project, assignees: [user], author: user, milestone: milestone, labels: labels }.freeze
create(:labeled_issue, ISSUE_PARAMS)
control = ActiveRecord::QueryRecorder.new { visit_milestone }
create(:labeled_issue, ISSUE_PARAMS)
expect { visit_milestone }.not_to exceed_query_limit(control)
end
private
def visit_milestone
visit(project_milestone_path(project, milestone))
end
end