2015-08-28 04:23:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MergeWorker do
|
|
|
|
describe "remove source branch" do
|
|
|
|
let!(:merge_request) { create(:merge_request, source_branch: "markdown") }
|
|
|
|
let!(:source_project) { merge_request.source_project }
|
|
|
|
let!(:project) { merge_request.project }
|
|
|
|
let!(:author) { merge_request.author }
|
|
|
|
|
|
|
|
before do
|
|
|
|
source_project.team << [author, :master]
|
2016-06-20 09:38:54 -04:00
|
|
|
source_project.repository.expire_branches_cache
|
2015-08-28 04:23:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'clears cache of source repo after removing source branch' do
|
|
|
|
expect(source_project.repository.branch_names).to include('markdown')
|
|
|
|
|
2017-05-01 11:13:33 -04:00
|
|
|
described_class.new.perform(
|
2015-08-28 04:23:56 -04:00
|
|
|
merge_request.id, merge_request.author_id,
|
|
|
|
commit_message: 'wow such merge',
|
|
|
|
should_remove_source_branch: true)
|
|
|
|
|
|
|
|
merge_request.reload
|
|
|
|
expect(merge_request).to be_merged
|
2016-04-01 15:21:08 -04:00
|
|
|
|
|
|
|
source_project.repository.expire_branches_cache
|
2015-08-28 04:23:56 -04:00
|
|
|
expect(source_project.repository.branch_names).not_to include('markdown')
|
|
|
|
end
|
|
|
|
end
|
2017-07-31 18:01:36 -04:00
|
|
|
|
|
|
|
it 'persists merge_jid' do
|
|
|
|
merge_request = create(:merge_request, merge_jid: nil)
|
|
|
|
user = create(:user)
|
|
|
|
worker = described_class.new
|
|
|
|
|
|
|
|
allow(worker).to receive(:jid) { '999' }
|
|
|
|
|
|
|
|
expect { worker.perform(merge_request.id, user.id, {}) }
|
|
|
|
.to change { merge_request.reload.merge_jid }.from(nil).to('999')
|
|
|
|
end
|
2015-08-28 04:23:56 -04:00
|
|
|
end
|