Commit f40bd9c2 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch 'pl-spec-ee-controller-projects-mr-perf' into 'master'

Speed up projects merge requests controller EE specs

See merge request gitlab-org/gitlab!46099
parents 1118c24c 208f5eb0
...@@ -4,8 +4,8 @@ require 'spec_helper' ...@@ -4,8 +4,8 @@ require 'spec_helper'
RSpec.shared_examples 'authorize read pipeline' do RSpec.shared_examples 'authorize read pipeline' do
context 'public project with private builds' do context 'public project with private builds' do
let_it_be(:project) { create(:project, :public, :builds_private) }
let(:comparison_status) { {} } let(:comparison_status) { {} }
let(:project) { create(:project, :public, :builds_private) }
it 'restricts access to signed out users' do it 'restricts access to signed out users' do
sign_out user sign_out user
...@@ -50,10 +50,11 @@ end ...@@ -50,10 +50,11 @@ end
RSpec.describe Projects::MergeRequestsController do RSpec.describe Projects::MergeRequestsController do
include ProjectForksHelper include ProjectForksHelper
let(:project) { create(:project, :repository) } let_it_be_with_refind(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: create(:user)) } let_it_be(:author) { create(:user) }
let(:user) { project.creator } let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: author) }
let(:viewer) { user } let(:user) { project.creator }
let(:viewer) { user }
before do before do
sign_in(viewer) sign_in(viewer)
...@@ -93,6 +94,10 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -93,6 +94,10 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'PUT update' do describe 'PUT update' do
let_it_be_with_reload(:merge_request) do
create(:merge_request_with_diffs, source_project: project, author: author)
end
before do before do
project.update(approvals_before_merge: 2) project.update(approvals_before_merge: 2)
end end
...@@ -371,7 +376,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -371,7 +376,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #dependency_scanning_reports' do describe 'GET #dependency_scanning_reports' do
let(:merge_request) { create(:ee_merge_request, :with_dependency_scanning_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_dependency_scanning_reports, source_project: project, author: author) }
let(:params) do let(:params) do
{ {
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
...@@ -443,7 +448,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -443,7 +448,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #container_scanning_reports' do describe 'GET #container_scanning_reports' do
let(:merge_request) { create(:ee_merge_request, :with_container_scanning_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_container_scanning_reports, source_project: project, author: author) }
let(:params) do let(:params) do
{ {
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
...@@ -515,7 +520,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -515,7 +520,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #sast_reports' do describe 'GET #sast_reports' do
let(:merge_request) { create(:ee_merge_request, :with_sast_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_sast_reports, source_project: project, author: author) }
let(:params) do let(:params) do
{ {
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
...@@ -587,7 +592,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -587,7 +592,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #coverage_fuzzing_reports' do describe 'GET #coverage_fuzzing_reports' do
let(:merge_request) { create(:ee_merge_request, :with_coverage_fuzzing_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_coverage_fuzzing_reports, source_project: project, author: author) }
let(:params) do let(:params) do
{ {
...@@ -733,7 +738,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -733,7 +738,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #secret_detection_reports' do describe 'GET #secret_detection_reports' do
let(:merge_request) { create(:ee_merge_request, :with_secret_detection_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_secret_detection_reports, source_project: project, author: author) }
let(:params) do let(:params) do
{ {
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
...@@ -806,7 +811,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -806,7 +811,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #dast_reports' do describe 'GET #dast_reports' do
let(:merge_request) { create(:ee_merge_request, :with_dast_reports, source_project: project) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_dast_reports, source_project: project) }
let(:params) do let(:params) do
{ {
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
...@@ -878,7 +883,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -878,7 +883,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #license_scanning_reports' do describe 'GET #license_scanning_reports' do
let(:merge_request) { create(:ee_merge_request, :with_license_scanning_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_license_scanning_reports, source_project: project, author: author) }
let(:comparison_status) { { status: :parsed, data: { new_licenses: [], existing_licenses: [], removed_licenses: [] } } } let(:comparison_status) { { status: :parsed, data: { new_licenses: [], existing_licenses: [], removed_licenses: [] } } }
let(:params) do let(:params) do
...@@ -973,6 +978,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -973,6 +978,7 @@ RSpec.describe Projects::MergeRequestsController do
context "when a user is NOT authorized to read licenses on a project" do context "when a user is NOT authorized to read licenses on a project" do
let(:project) { create(:project, :repository, :private) } let(:project) { create(:project, :repository, :private) }
let(:merge_request) { create(:ee_merge_request, :with_license_scanning_reports, source_project: project, author: create(:user)) }
let(:viewer) { create(:user) } let(:viewer) { create(:user) }
it 'returns a report' do it 'returns a report' do
...@@ -984,6 +990,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -984,6 +990,7 @@ RSpec.describe Projects::MergeRequestsController do
context "when a user is authorized to read the licenses" do context "when a user is authorized to read the licenses" do
let(:project) { create(:project, :repository, :private) } let(:project) { create(:project, :repository, :private) }
let(:merge_request) { create(:ee_merge_request, :with_license_scanning_reports, source_project: project, author: create(:user)) }
let(:viewer) { create(:user) } let(:viewer) { create(:user) }
before do before do
...@@ -1017,7 +1024,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -1017,7 +1024,7 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'GET #metrics_reports' do describe 'GET #metrics_reports' do
let(:merge_request) { create(:ee_merge_request, :with_metrics_reports, source_project: project, author: create(:user)) } let_it_be_with_reload(:merge_request) { create(:ee_merge_request, :with_metrics_reports, source_project: project, author: author) }
let(:params) do let(:params) do
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment