diff options
author | Robert Speicher <robert@gitlab.com> | 2017-12-04 19:20:01 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-12-04 19:20:01 +0000 |
commit | f3a3bd50eafdcfcaeea21d6cfa0b8bbae7720fec (patch) | |
tree | f11390dcf7b4bbfd103d33f5c79a4ed5524836c0 /spec | |
parent | c7940733b410d5f55bbe150dd9b44453fdc9a731 (diff) | |
parent | 8be9567c64d2c90a56e36308f39ee89938137614 (diff) | |
download | gitlab-ce-f3a3bd50eafdcfcaeea21d6cfa0b8bbae7720fec.tar.gz |
Merge branch 'feature/migrate-cherry-pick-to-gitaly' into 'master'
Migrate Gitlab::Git::Repository#cherry_pick to Gitaly
Closes gitaly#737
See merge request gitlab-org/gitlab-ce!15517
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 27f0a99b2fa..af0c86abe86 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1408,42 +1408,52 @@ describe Repository do end describe '#cherry_pick' do - let(:conflict_commit) { repository.commit('c642fe9b8b9f28f9225d7ea953fe14e74748d53b') } - let(:pickable_commit) { repository.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') } - let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') } - let(:message) { 'cherry-pick message' } - - context 'when there is a conflict' do - it 'raises an error' do - expect { repository.cherry_pick(user, conflict_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError) + shared_examples 'cherry-picking a commit' do + let(:conflict_commit) { repository.commit('c642fe9b8b9f28f9225d7ea953fe14e74748d53b') } + let(:pickable_commit) { repository.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') } + let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') } + let(:message) { 'cherry-pick message' } + + context 'when there is a conflict' do + it 'raises an error' do + expect { repository.cherry_pick(user, conflict_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError) + end end - end - context 'when commit was already cherry-picked' do - it 'raises an error' do - repository.cherry_pick(user, pickable_commit, 'master', message) + context 'when commit was already cherry-picked' do + it 'raises an error' do + repository.cherry_pick(user, pickable_commit, 'master', message) - expect { repository.cherry_pick(user, pickable_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError) + expect { repository.cherry_pick(user, pickable_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError) + end end - end - context 'when commit can be cherry-picked' do - it 'cherry-picks the changes' do - expect(repository.cherry_pick(user, pickable_commit, 'master', message)).to be_truthy + context 'when commit can be cherry-picked' do + it 'cherry-picks the changes' do + expect(repository.cherry_pick(user, pickable_commit, 'master', message)).to be_truthy + end end - end - context 'cherry-picking a merge commit' do - it 'cherry-picks the changes' do - expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).to be_nil + context 'cherry-picking a merge commit' do + it 'cherry-picks the changes' do + expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).to be_nil - cherry_pick_commit_sha = repository.cherry_pick(user, pickable_merge, 'improve/awesome', message) - cherry_pick_commit_message = project.commit(cherry_pick_commit_sha).message + cherry_pick_commit_sha = repository.cherry_pick(user, pickable_merge, 'improve/awesome', message) + 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 eq(message) + expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).not_to be_nil + expect(cherry_pick_commit_message).to eq(message) + end end end + + context 'when Gitaly cherry_pick feature is enabled' do + it_behaves_like 'cherry-picking a commit' + end + + context 'when Gitaly cherry_pick feature is disabled', :disable_gitaly do + it_behaves_like 'cherry-picking a commit' + end end describe '#before_delete' do |