2019-03-30 03:15:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-20 04:01:21 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe RebaseWorker, '#perform' do
|
2018-08-31 13:16:34 -04:00
|
|
|
include ProjectForksHelper
|
|
|
|
|
2017-12-20 04:01:21 -05:00
|
|
|
context 'when rebasing an MR from a fork where upstream has protected branches' do
|
|
|
|
let(:upstream_project) { create(:project, :repository) }
|
2018-08-31 13:16:34 -04:00
|
|
|
let(:forked_project) { fork_project(upstream_project, nil, repository: true) }
|
2017-12-20 04:01:21 -05:00
|
|
|
|
|
|
|
let(:merge_request) do
|
|
|
|
create(:merge_request,
|
2018-08-31 13:16:34 -04:00
|
|
|
source_project: forked_project,
|
2017-12-20 04:01:21 -05:00
|
|
|
source_branch: 'feature_conflict',
|
|
|
|
target_project: upstream_project,
|
|
|
|
target_branch: 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets the correct project for running hooks' do
|
|
|
|
expect(MergeRequests::RebaseService)
|
2018-08-31 13:16:34 -04:00
|
|
|
.to receive(:new).with(forked_project, merge_request.author).and_call_original
|
2017-12-20 04:01:21 -05:00
|
|
|
|
2018-11-26 17:14:59 -05:00
|
|
|
subject.perform(merge_request.id, merge_request.author.id)
|
2017-12-20 04:01:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|