Commit 1af30cd8 authored by Fabio Pitino's avatar Fabio Pitino

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

Speed up projects merge requests controller specs

See merge request gitlab-org/gitlab!46098
parents c915477a 81ad5c9c
......@@ -842,7 +842,6 @@ Rails/SaveBang:
- 'spec/controllers/projects/imports_controller_spec.rb'
- 'spec/controllers/projects/issues_controller_spec.rb'
- 'spec/controllers/projects/labels_controller_spec.rb'
- 'spec/controllers/projects/merge_requests_controller_spec.rb'
- 'spec/controllers/projects/milestones_controller_spec.rb'
- 'spec/controllers/projects/notes_controller_spec.rb'
- 'spec/controllers/projects/pipelines_controller_spec.rb'
......
......@@ -6,14 +6,10 @@ RSpec.describe Projects::MergeRequestsController do
include ProjectForksHelper
include Gitlab::Routing
let(:project) { create(:project, :repository) }
let_it_be_with_refind(:project) { create(:project, :repository) }
let_it_be_with_reload(:project_public_with_private_builds) { create(:project, :repository, :public, :builds_private) }
let(:user) { project.owner }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:merge_request_with_conflicts) do
create(:merge_request, source_branch: 'conflict-resolvable', target_branch: 'conflict-start', source_project: project, merge_status: :unchecked) do |mr|
mr.mark_as_unmergeable
end
end
before do
sign_in(user)
......@@ -107,7 +103,7 @@ RSpec.describe Projects::MergeRequestsController do
render_views
it 'renders merge request page' do
merge_request.merge_request_diff.destroy
merge_request.merge_request_diff.destroy!
go(format: :html)
......@@ -147,7 +143,7 @@ RSpec.describe Projects::MergeRequestsController do
let(:new_project) { create(:project) }
before do
project.route.destroy
project.route.destroy!
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
......@@ -359,12 +355,11 @@ RSpec.describe Projects::MergeRequestsController do
end
context 'there is no source project' do
let(:project) { create(:project, :repository) }
let(:forked_project) { fork_project_with_submodules(project) }
let!(:merge_request) { create(:merge_request, source_project: forked_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
before do
forked_project.destroy
forked_project.destroy!
end
it 'closes MR without errors' do
......@@ -435,7 +430,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'when the merge request is not mergeable' do
before do
merge_request.update(title: "WIP: #{merge_request.title}")
merge_request.update!(title: "WIP: #{merge_request.title}")
post :merge, params: base_params
end
......@@ -475,7 +470,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'when squash is passed as 1' do
it 'updates the squash attribute on the MR to true' do
merge_request.update(squash: false)
merge_request.update!(squash: false)
merge_with_sha(squash: '1')
expect(merge_request.reload.squash_on_merge?).to be_truthy
......@@ -484,7 +479,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'when squash is passed as 0' do
it 'updates the squash attribute on the MR to false' do
merge_request.update(squash: true)
merge_request.update!(squash: true)
merge_with_sha(squash: '0')
expect(merge_request.reload.squash_on_merge?).to be_falsey
......@@ -547,7 +542,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'and head pipeline is not the current one' do
before do
head_pipeline.update(sha: 'not_current_sha')
head_pipeline.update!(sha: 'not_current_sha')
end
it 'returns :failed' do
......@@ -667,9 +662,9 @@ RSpec.describe Projects::MergeRequestsController do
end
context "when the user is owner" do
let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:project, :repository, namespace: namespace) }
let_it_be(:owner) { create(:user) }
let_it_be(:namespace) { create(:namespace, owner: owner) }
let_it_be(:project) { create(:project, :repository, namespace: namespace) }
before do
sign_in owner
......@@ -765,7 +760,7 @@ RSpec.describe Projects::MergeRequestsController do
end
context 'with private builds on a public project' do
let(:project) { create(:project, :repository, :public, :builds_private) }
let(:project) { project_public_with_private_builds }
context 'for a project owner' do
it 'responds with serialized pipelines' do
......@@ -813,7 +808,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'with public builds' do
let(:forked_project) do
fork_project(project, fork_user, repository: true).tap do |new_project|
new_project.project_feature.update(builds_access_level: ProjectFeature::ENABLED)
new_project.project_feature.update!(builds_access_level: ProjectFeature::ENABLED)
end
end
......@@ -855,7 +850,7 @@ RSpec.describe Projects::MergeRequestsController do
end
describe 'GET exposed_artifacts' do
let(:merge_request) do
let_it_be(:merge_request) do
create(:merge_request,
:with_merge_request_pipeline,
target_project: project,
......@@ -993,7 +988,7 @@ RSpec.describe Projects::MergeRequestsController do
end
describe 'GET coverage_reports' do
let(:merge_request) do
let_it_be(:merge_request) do
create(:merge_request,
:with_merge_request_pipeline,
target_project: project,
......@@ -1123,7 +1118,7 @@ RSpec.describe Projects::MergeRequestsController do
end
describe 'GET terraform_reports' do
let(:merge_request) do
let_it_be(:merge_request) do
create(:merge_request,
:with_merge_request_pipeline,
target_project: project,
......@@ -1271,7 +1266,7 @@ RSpec.describe Projects::MergeRequestsController do
end
describe 'GET test_reports' do
let(:merge_request) do
let_it_be(:merge_request) do
create(:merge_request,
:with_diffs,
:with_merge_request_pipeline,
......@@ -1382,7 +1377,7 @@ RSpec.describe Projects::MergeRequestsController do
end
describe 'GET accessibility_reports' do
let(:merge_request) do
let_it_be(:merge_request) do
create(:merge_request,
:with_diffs,
:with_merge_request_pipeline,
......@@ -1419,7 +1414,7 @@ RSpec.describe Projects::MergeRequestsController do
end
context 'permissions on a public project with private CI/CD' do
let(:project) { create(:project, :repository, :public, :builds_private) }
let(:project) { project_public_with_private_builds }
let(:accessibility_comparison) { { status: :parsed, data: { summary: 1 } } }
context 'while signed out' do
......@@ -1505,7 +1500,7 @@ RSpec.describe Projects::MergeRequestsController do
describe 'POST remove_wip' do
before do
merge_request.title = merge_request.wip_title
merge_request.save
merge_request.save!
post :remove_wip,
params: {
......@@ -1626,7 +1621,7 @@ RSpec.describe Projects::MergeRequestsController do
it 'links to the environment on that project', :sidekiq_might_not_need_inline do
get_ci_environments_status
expect(json_response.first['url']).to match /#{forked.full_path}/
expect(json_response.first['url']).to match(/#{forked.full_path}/)
end
context "when environment_target is 'merge_commit'", :sidekiq_might_not_need_inline do
......@@ -1653,7 +1648,7 @@ RSpec.describe Projects::MergeRequestsController do
get_ci_environments_status(environment_target: 'merge_commit')
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.first['url']).to match /#{project.full_path}/
expect(json_response.first['url']).to match(/#{project.full_path}/)
end
end
end
......@@ -1773,7 +1768,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'with project member visibility on a public project' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, :public, :builds_private) }
let(:project) { project_public_with_private_builds }
it 'returns pipeline data to project members' do
project.add_developer(user)
......
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