diff options
| author | P.S.V.R <pmq2001@gmail.com> | 2016-04-18 15:39:07 +0800 |
|---|---|---|
| committer | P.S.V.R <pmq2001@gmail.com> | 2016-04-18 15:39:07 +0800 |
| commit | 3d6ba3b1076e68a67691d0e0de24ef97cc07f119 (patch) | |
| tree | 33b3169a49a26b01cfed23d5cd1bb29b748f8784 /spec/models | |
| parent | e9f20f5922e9c365b4af14e53881a7bafba4139c (diff) | |
| download | gitlab-ce-3d6ba3b1076e68a67691d0e0de24ef97cc07f119.tar.gz | |
Add support to cherry-pick any commit
Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/12785
Merge Request: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3514
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/repository_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index c163001b7c1..efd6da582b3 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -541,6 +541,41 @@ describe Repository, models: true do end end + describe '#cherry_pick' do + let(:conflict_commit) { repository.commit('c642fe9b8b9f28f9225d7ea953fe14e74748d53b') } + let(:pickable_commit) { repository.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') } + let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') } + + context 'when there is a conflict' do + it 'should abort the operation' do + expect(repository.cherry_pick(user, conflict_commit, 'master')).to eq(false) + end + end + + context 'when commit was already cherry-picked' do + it 'should abort the operation' do + repository.cherry_pick(user, pickable_commit, 'master') + + expect(repository.cherry_pick(user, pickable_commit, 'master')).to eq(false) + end + end + + context 'when commit can be cherry-picked' do + it 'should cherry-pick the changes' do + expect(repository.cherry_pick(user, pickable_commit, 'master')).to be_truthy + end + end + + context 'cherry-picking a merge commit' do + it 'should cherry-pick the changes' do + expect(repository.blob_at_branch('master', 'foo/bar/.gitkeep')).to be_nil + + repository.cherry_pick(user, pickable_merge, 'master') + expect(repository.blob_at_branch('master', 'foo/bar/.gitkeep')).not_to be_nil + end + end + end + describe '#before_delete' do describe 'when a repository does not exist' do before do |
