summaryrefslogtreecommitdiff
path: root/spec/models/commit_spec.rb
diff options
context:
space:
mode:
authorSaverio Miroddi <saverio.pub2@gmail.com>2017-08-21 21:05:11 +0200
committerSaverio Miroddi <saverio.pub2@gmail.com>2017-08-21 21:05:11 +0200
commite6220c018eec5a9fdf2491651b00863c5b8a54c0 (patch)
tree5becadac9d1076357251e8218f9bab7c5ff0b0ca /spec/models/commit_spec.rb
parent83417865d06226d23edde69cf98b3d3b88aff07f (diff)
downloadgitlab-ce-e6220c018eec5a9fdf2491651b00863c5b8a54c0.tar.gz
Add UT for cherry-pick of an existing merge that is not found
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r--spec/models/commit_spec.rb49
1 files changed, 30 insertions, 19 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 25de444da11..d35eeae00f3 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -212,39 +212,50 @@ eos
{ message: 'Test message', committer: author, author: author }
end
- let(:merge_commit) do
- merge_request = create(:merge_request,
- source_branch: 'video',
- target_branch: 'master',
- source_project: project,
- author: user)
+ let(:merge_request) do
+ create(:merge_request,
+ source_branch: 'video',
+ target_branch: 'master',
+ source_project: project,
+ author: user)
+ end
+ let(:merge_commit) do
merge_commit_id = repository.merge(user,
merge_request.diff_head_sha,
merge_request,
commit_options)
- merge_commit = repository.commit(merge_commit_id)
+ repository.commit(merge_commit_id)
+ end
- # Manually mark as completed.
- #
- merge_request.update(merge_commit_sha: merge_commit_id)
+ context 'that is found' do
+ before do
+ # Artificially mark as completed.
+ merge_request.update(merge_commit_sha: merge_commit.id)
+ end
- merge_commit
- end
+ it do
+ expected_appended_text = <<~STR.rstrip
- it do
- expected_appended_text = <<~STR.rstrip
+ (cherry picked from commit #{merge_commit.sha})
- (cherry picked from commit #{merge_commit.sha})
+ 467dc98f Add new 'videos' directory
+ 88790590 Upload new video file
+ STR
- 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
- expect(merge_commit.cherry_pick_message(user)).to include(expected_appended_text)
+ 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
describe '#reverts_commit?' do