diff options
author | Saverio Miroddi <saverio.pub2@gmail.com> | 2017-08-17 20:26:06 +0200 |
---|---|---|
committer | Saverio Miroddi <saverio.pub2@gmail.com> | 2017-08-17 22:38:47 +0200 |
commit | c0f921606c91e3e5c601497f57becbf4c6a8e3ac (patch) | |
tree | 3cb77d0f5b837d16fd572946be9d308541d54d85 /spec/models/commit_spec.rb | |
parent | 919c0c7ba7369970bf57e9388333af120b74203d (diff) | |
download | gitlab-ce-c0f921606c91e3e5c601497f57becbf4c6a8e3ac.tar.gz |
Correct the cherry-pick message for merge commits
The list of commits must be generated from the merge request,
not from a diff of the branches.
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r-- | spec/models/commit_spec.rb | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 9711222b3a1..98054b91c29 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -196,25 +196,52 @@ eos end describe '#cherry_pick_message' do - let(:regular_commit) { project.commit('video') } - let(:merge_commit) { project.commit('wip') } + let(:user) { create(:user) } context 'of a regular commit' do - it { expect(regular_commit.cherry_pick_message(project, 'master')).to include("\n\n(cherry picked from commit 88790590ed1337ab189bccaa355f068481c90bec)") } + let(:commit) { project.commit('video') } + + it { expect(commit.cherry_pick_message(user)).to include("\n\n(cherry picked from commit 88790590ed1337ab189bccaa355f068481c90bec)") } end context 'of a merge commit' do + let(:repository) { project.repository } + + let(:commit_options) do + author = repository.user_to_committer(user) + commit_options = { message: 'Test message', committer: author, author: author } + end + + let(:merge_commit) do + merge_request = create(:merge_request, + source_branch: 'feature', + target_branch: 'master', + source_project: project, + author: user) + + merge_commit_id = repository.merge(user, + merge_request.diff_head_sha, + merge_request, + commit_options) + + merge_commit = repository.commit(merge_commit_id) + + # Manually mark as completed. + # + merge_request.update(merge_commit_sha: merge_commit_id) + + merge_commit + end + it do expected_appended_text = <<~STR.rstrip + (cherry picked from commit #{merge_commit.sha}) - (cherry picked from commit b9238ee5bf1d7359dd3b8c89fd76c1c7f8b75aba) - - 6d664995 This commit will be fixupped against - 64117577 fixup! This commit will be fixupped against + 0b4bc9a4 Feature added STR - expect(merge_commit.cherry_pick_message(project, 'master')).to include(expected_appended_text) + expect(merge_commit.cherry_pick_message(user)).to include(expected_appended_text) end end end |