Commit 9956117c authored by nicolasdular's avatar nicolasdular

De-dupe MR create service EE specs

De-duplicates the MR create service specs
parent c8557573
...@@ -217,12 +217,10 @@ Gitlab/DuplicateSpecLocation: ...@@ -217,12 +217,10 @@ Gitlab/DuplicateSpecLocation:
- ee/spec/helpers/auth_helper_spec.rb - ee/spec/helpers/auth_helper_spec.rb
- ee/spec/lib/gitlab/gl_repository_spec.rb - ee/spec/lib/gitlab/gl_repository_spec.rb
- ee/spec/models/namespace_spec.rb - ee/spec/models/namespace_spec.rb
- ee/spec/services/merge_requests/create_service_spec.rb
- ee/spec/services/merge_requests/refresh_service_spec.rb - ee/spec/services/merge_requests/refresh_service_spec.rb
- ee/spec/services/merge_requests/update_service_spec.rb - ee/spec/services/merge_requests/update_service_spec.rb
- ee/spec/helpers/ee/auth_helper_spec.rb - ee/spec/helpers/ee/auth_helper_spec.rb
- ee/spec/models/ee/namespace_spec.rb - ee/spec/models/ee/namespace_spec.rb
- ee/spec/services/ee/merge_requests/create_service_spec.rb
- ee/spec/services/ee/merge_requests/refresh_service_spec.rb - ee/spec/services/ee/merge_requests/refresh_service_spec.rb
- ee/spec/services/ee/merge_requests/update_service_spec.rb - ee/spec/services/ee/merge_requests/update_service_spec.rb
......
...@@ -6,7 +6,6 @@ describe MergeRequests::CreateService do ...@@ -6,7 +6,6 @@ describe MergeRequests::CreateService do
include ProjectForksHelper include ProjectForksHelper
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user, opts) } let(:service) { described_class.new(project, user, opts) }
let(:opts) do let(:opts) do
{ {
...@@ -19,11 +18,16 @@ describe MergeRequests::CreateService do ...@@ -19,11 +18,16 @@ describe MergeRequests::CreateService do
end end
before do before do
project.add_maintainer(user)
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
end end
describe '#execute' do describe '#execute' do
let(:user) { create(:user) }
before do
project.add_maintainer(user)
end
it 'refreshes code owners for the merge request' do it 'refreshes code owners for the merge request' do
fake_refresh_service = instance_double(::MergeRequests::SyncCodeOwnerApprovalRules) fake_refresh_service = instance_double(::MergeRequests::SyncCodeOwnerApprovalRules)
...@@ -69,4 +73,25 @@ describe MergeRequests::CreateService do ...@@ -69,4 +73,25 @@ describe MergeRequests::CreateService do
let(:parent) { project } let(:parent) { project }
end end
end end
describe '#execute with blocking merge requests', :clean_gitlab_redis_shared_state do
let(:opts) { { title: 'Blocked MR', source_branch: 'feature', target_branch: 'master' } }
let(:user) { project.owner }
it 'delegates to MergeRequests::UpdateBlocksService' do
expect(MergeRequests::UpdateBlocksService)
.to receive(:extract_params!)
.and_return(:extracted_params)
expect_next_instance_of(MergeRequests::UpdateBlocksService) do |block_service|
expect(block_service.merge_request.title).to eq('Blocked MR')
expect(block_service.current_user).to eq(user)
expect(block_service.params).to eq(:extracted_params)
expect(block_service).to receive(:execute)
end
service.execute
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
subject(:service) { described_class.new(project, user, params) }
describe '#execute' do
context 'with blocking merge requests' do
let(:params) { { title: 'Blocked MR', source_branch: 'feature', target_branch: 'master' } }
it 'delegates to MergeRequests::UpdateBlocksService' do
expect(MergeRequests::UpdateBlocksService)
.to receive(:extract_params!)
.and_return(:extracted_params)
expect_next_instance_of(MergeRequests::UpdateBlocksService) do |block_service|
expect(block_service.merge_request.title).to eq('Blocked MR')
expect(block_service.current_user).to eq(user)
expect(block_service.params).to eq(:extracted_params)
expect(block_service).to receive(:execute)
end
service.execute
end
end
end
end
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