diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2017-09-25 23:01:04 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2017-09-29 01:53:49 +0300 |
commit | 4f5be9ec7bfd4813eaac630c9232cd5335a5076b (patch) | |
tree | a9ecb86a82296b7fbfa17dbb2ed36b30e4fcf165 /spec/models/repository_spec.rb | |
parent | 07c3112ef540a78c4a84281368eb975ba27a1f4c (diff) |
Migrate Gitlab::Git::Repository#add_tag to Gitaly
Closes gitaly#601
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index e63977adec8..525c4027e5f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1617,27 +1617,41 @@ describe Repository do end describe '#add_tag' do - context 'with a valid target' do - let(:user) { build_stubbed(:user) } + let(:user) { build_stubbed(:user) } - it 'creates the tag using rugged' do - expect(repository.rugged.tags).to receive(:create) - .with('8.5', repository.commit('master').id, - hash_including(message: 'foo', - tagger: hash_including(name: user.name, email: user.email))) - .and_call_original + shared_examples 'adding tag' do + context 'with a valid target' do + it 'creates the tag' do + repository.add_tag(user, '8.5', 'master', 'foo') - repository.add_tag(user, '8.5', 'master', 'foo') - end + tag = repository.find_tag('8.5') + expect(tag).to be_present + expect(tag.message).to eq('foo') + expect(tag.dereferenced_target.id).to eq(repository.commit('master').id) + end - it 'returns a Gitlab::Git::Tag object' do - tag = repository.add_tag(user, '8.5', 'master', 'foo') + it 'returns a Gitlab::Git::Tag object' do + tag = repository.add_tag(user, '8.5', 'master', 'foo') + + expect(tag).to be_a(Gitlab::Git::Tag) + end + end - expect(tag).to be_a(Gitlab::Git::Tag) + context 'with an invalid target' do + it 'returns false' do + expect(repository.add_tag(user, '8.5', 'bar', 'foo')).to be false + end end + end - it 'passes commit SHA to pre-receive and update hooks,\ - and tag SHA to post-receive hook' do + context 'when Gitaly operation_user_add_tag feature is enabled' do + it_behaves_like 'adding tag' + end + + context 'when Gitaly operation_user_add_tag feature is disabled', skip_gitaly_mock: true do + it_behaves_like 'adding tag' + + it 'passes commit SHA to pre-receive and update hooks and tag SHA to post-receive hook' do pre_receive_hook = Gitlab::Git::Hook.new('pre-receive', project) update_hook = Gitlab::Git::Hook.new('update', project) post_receive_hook = Gitlab::Git::Hook.new('post-receive', project) @@ -1662,12 +1676,6 @@ describe Repository do .with(anything, anything, tag_sha, anything) end end - - context 'with an invalid target' do - it 'returns false' do - expect(repository.add_tag(user, '8.5', 'bar', 'foo')).to be false - end - end end describe '#rm_branch' do |