2019-03-30 03:15:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-28 04:23:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe MergeWorker do
|
2015-08-28 04:23:56 -04:00
|
|
|
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
|
2018-07-11 10:36:08 -04:00
|
|
|
source_project.add_maintainer(author)
|
2016-06-20 09:38:54 -04:00
|
|
|
source_project.repository.expire_branches_cache
|
2015-08-28 04:23:56 -04:00
|
|
|
end
|
|
|
|
|
2021-03-02 04:10:43 -05:00
|
|
|
it 'clears cache of source repo after removing source branch', :sidekiq_inline do
|
2015-08-28 04:23:56 -04:00
|
|
|
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',
|
2019-11-15 10:06:12 -05:00
|
|
|
sha: merge_request.diff_head_sha,
|
2015-08-28 04:23:56 -04:00
|
|
|
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
|
2021-04-26 11:10:20 -04:00
|
|
|
|
|
|
|
it_behaves_like 'an idempotent worker' do
|
|
|
|
let(:job_args) do
|
|
|
|
[
|
|
|
|
merge_request.id,
|
|
|
|
merge_request.author_id,
|
|
|
|
commit_message: 'wow such merge',
|
|
|
|
sha: merge_request.diff_head_sha
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'the merge request is still shown as merged' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
merge_request.reload
|
|
|
|
expect(merge_request).to be_merged
|
|
|
|
end
|
|
|
|
end
|
2015-08-28 04:23:56 -04:00
|
|
|
end
|
|
|
|
end
|