Add UT for cherry-pick of an existing merge that is not found

This commit is contained in:
Saverio Miroddi 2017-08-21 21:05:11 +02:00
parent 83417865d0
commit e6220c018e
1 changed files with 31 additions and 20 deletions

View File

@ -212,39 +212,50 @@ eos
{ message: 'Test message', committer: author, author: author } { message: 'Test message', committer: author, author: author }
end end
let(:merge_commit) do let(:merge_request) do
merge_request = create(:merge_request, create(:merge_request,
source_branch: 'video', source_branch: 'video',
target_branch: 'master', target_branch: 'master',
source_project: project, source_project: project,
author: user) author: user)
end
let(:merge_commit) do
merge_commit_id = repository.merge(user, merge_commit_id = repository.merge(user,
merge_request.diff_head_sha, merge_request.diff_head_sha,
merge_request, merge_request,
commit_options) commit_options)
merge_commit = repository.commit(merge_commit_id) repository.commit(merge_commit_id)
# Manually mark as completed.
#
merge_request.update(merge_commit_sha: merge_commit_id)
merge_commit
end end
it do context 'that is found' do
expected_appended_text = <<~STR.rstrip before do
# Artificially mark as completed.
merge_request.update(merge_commit_sha: merge_commit.id)
end
(cherry picked from commit #{merge_commit.sha}) it do
expected_appended_text = <<~STR.rstrip
467dc98f Add new 'videos' directory (cherry picked from commit #{merge_commit.sha})
88790590 Upload new video file
STR
expect(merge_commit.cherry_pick_message(user)).to include(expected_appended_text) 467dc98f Add new 'videos' directory
88790590 Upload new video file
STR
expect(merge_commit.cherry_pick_message(user)).to include(expected_appended_text)
end
end end
context "that is existing but not found (eg. it's in progress)" do
it do
expect(merge_commit.cherry_pick_message(user)).to end_with("(cherry picked from commit #{merge_commit.sha})")
end
end
end end
end end
describe '#reverts_commit?' do describe '#reverts_commit?' do