2016-03-22 10:34:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Projects::UnlinkForkService do
|
2017-07-25 13:09:00 -04:00
|
|
|
subject { described_class.new(fork_project, user) }
|
2016-03-22 10:34:35 -04:00
|
|
|
|
|
|
|
let(:fork_link) { create(:forked_project_link) }
|
|
|
|
let(:fork_project) { fork_link.forked_to_project }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
context 'with opened merge request on the source project' do
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: fork_project, target_project: fork_link.forked_from_project) }
|
|
|
|
let(:mr_close_service) { MergeRequests::CloseService.new(fork_project, user) }
|
|
|
|
|
|
|
|
before do
|
2017-06-21 09:48:12 -04:00
|
|
|
allow(MergeRequests::CloseService).to receive(:new)
|
|
|
|
.with(fork_project, user)
|
|
|
|
.and_return(mr_close_service)
|
2016-03-22 10:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'close all pending merge requests' do
|
|
|
|
expect(mr_close_service).to receive(:execute).with(merge_request)
|
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'remove fork relation' do
|
2016-04-03 11:17:14 -04:00
|
|
|
expect(fork_project.forked_project_link).to receive(:destroy)
|
2016-03-22 10:34:35 -04:00
|
|
|
|
2016-04-03 11:17:14 -04:00
|
|
|
subject.execute
|
2016-03-22 10:34:35 -04:00
|
|
|
end
|
|
|
|
end
|