summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaverio Miroddi <saverio.pub2@gmail.com>2017-08-16 13:18:07 +0200
committerSaverio Miroddi <saverio.pub2@gmail.com>2017-08-16 13:18:07 +0200
commit919c0c7ba7369970bf57e9388333af120b74203d (patch)
treecb6eaa5abf89af56821682bfc7761cc82a614441
parentae5e806f128e8e737948f4286da92526c74c316e (diff)
downloadgitlab-ce-919c0c7ba7369970bf57e9388333af120b74203d.tar.gz
Extended UTs for the new cherry-pick message format
-rw-r--r--spec/models/commit_spec.rb24
-rw-r--r--spec/models/repository_spec.rb5
2 files changed, 28 insertions, 1 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index c18c635d811..9711222b3a1 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -195,6 +195,30 @@ eos
it { expect(data[:removed]).to eq([]) }
end
+ describe '#cherry_pick_message' do
+ let(:regular_commit) { project.commit('video') }
+ let(:merge_commit) { project.commit('wip') }
+
+ context 'of a regular commit' do
+ it { expect(regular_commit.cherry_pick_message(project, 'master')).to include("\n\n(cherry picked from commit 88790590ed1337ab189bccaa355f068481c90bec)") }
+ end
+
+ context 'of a merge commit' do
+ it do
+ expected_appended_text = <<~STR.rstrip
+
+
+ (cherry picked from commit b9238ee5bf1d7359dd3b8c89fd76c1c7f8b75aba)
+
+ 6d664995 This commit will be fixupped against
+ 64117577 fixup! This commit will be fixupped against
+ STR
+
+ expect(merge_commit.cherry_pick_message(project, 'master')).to include(expected_appended_text)
+ end
+ end
+ end
+
describe '#reverts_commit?' do
let(:another_commit) { double(:commit, revert_description: "This reverts commit #{commit.sha}") }
let(:user) { commit.author }
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 4926d5d6c49..c407799e47e 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1344,8 +1344,11 @@ describe Repository, models: true do
it 'cherry-picks the changes' do
expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).to be_nil
- repository.cherry_pick(user, pickable_merge, 'improve/awesome')
+ cherry_pick_commit_sha = repository.cherry_pick(user, pickable_merge, 'improve/awesome')
+ cherry_pick_commit_message = project.commit(cherry_pick_commit_sha).message
+
expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).not_to be_nil
+ expect(cherry_pick_commit_message).to include('cherry picked from')
end
end
end