diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-25 17:31:45 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-05-04 18:19:13 +0300 |
commit | 209f2f1e6fd861dd7bb6a73389400b4bb266d26d (patch) | |
tree | 6b945d01503fd1b52a7d8b73fe162f69144d257f /spec/models | |
parent | 44f89eafc08a7967544429a3f930354a5f9bbbaf (diff) |
Use a similar approach to branch creation for tag creation
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/repository_spec.rb | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 5cdf644a0e1..b3359a42237 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -858,16 +858,30 @@ describe Repository, models: true do end describe '#add_tag' do - it 'adds a tag' do - user = build_stubbed(:user) - expect(repository).to receive(:before_push_tag) - expect(repository.rugged.tags).to receive(:create). - with('8.5', 'master', - hash_including(message: 'foo', - tagger: hash_including(name: user.name, email: user.email))). - and_call_original - - repository.add_tag(user, '8.5', 'master', 'foo') + context 'with a valid target' do + 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 + + repository.add_tag(user, '8.5', 'master', 'foo') + end + + 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 + + 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 |