debian-mirror-gitlab/spec/services/projects/unlink_fork_service_spec.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Projects::UnlinkForkService do
subject { described_class.new(fork_project, user) }
2016-06-02 11:05:42 +05:30
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-09-10 17:25:29 +05:30
allow(MergeRequests::CloseService).to receive(:new)
.with(fork_project, user)
.and_return(mr_close_service)
2016-06-02 11:05:42 +05:30
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
expect(fork_project.forked_project_link).to receive(:destroy)
subject.execute
end
2017-09-10 17:25:29 +05:30
it 'refreshes the forks count cache of the source project' do
source = fork_project.forked_from_project
expect(source.forks_count).to eq(1)
subject.execute
expect(source.forks_count).to be_zero
end
2016-06-02 11:05:42 +05:30
end