diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-09-13 13:48:06 +0300 |
---|---|---|
committer | Yorick Peterse <yorick@yorickpeterse.com> | 2019-09-30 15:22:05 +0300 |
commit | 58290d90e5b642322e397d197eb063a3ff712008 (patch) | |
tree | badc57fd28b52968a34a388b32caccc1d1aa7464 /spec/requests/groups | |
parent | 48bb855ece50ca7b53b821cfcf3d335a8106e286 (diff) |
Hide disabled project milestones in project settings on group level
Diffstat (limited to 'spec/requests/groups')
-rw-r--r-- | spec/requests/groups/milestones_controller_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/requests/groups/milestones_controller_spec.rb b/spec/requests/groups/milestones_controller_spec.rb new file mode 100644 index 00000000000..af19d931284 --- /dev/null +++ b/spec/requests/groups/milestones_controller_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Groups::MilestonesController do + context 'N+1 DB queries' do + let(:user) { create(:user) } + let!(:public_group) { create(:group, :public) } + + let!(:public_project_with_private_issues_and_mrs) do + create(:project, :public, :issues_private, :merge_requests_private, group: public_group) + end + let!(:private_milestone) { create(:milestone, project: public_project_with_private_issues_and_mrs, title: 'project milestone') } + + it 'avoids N+1 database queries' do + public_project = create(:project, :public, :merge_requests_enabled, :issues_enabled, group: public_group) + create(:milestone, project: public_project) + + control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) { get "/groups/#{public_group.to_param}/-/milestones.json" }.count + + projects = create_list(:project, 2, :public, :merge_requests_enabled, :issues_enabled, group: public_group) + projects.each do |project| + create(:milestone, project: project) + end + + expect { get "/groups/#{public_group.to_param}/-/milestones.json" }.not_to exceed_all_query_limit(control_count) + expect(response).to have_http_status(200) + milestones = json_response + + expect(milestones.count).to eq(3) + expect(milestones.map {|x| x['title']}).not_to include(private_milestone.title) + end + end +end |