diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-11-18 18:49:07 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-11-18 18:49:07 +0300 |
commit | c55733bc5058b793389101cce47b9b5807d73fd0 (patch) | |
tree | 6b720c847f38edb3545da5c4123d754cefad389b /spec | |
parent | 50b95f31396e37900e4f3176a746bb668e10745c (diff) | |
parent | ae51774bc45d2e15ccc61b01a30d1b588f179f85 (diff) |
Merge branch 'pass-correct-tag-target-to-post-receive' into 'master'
Pass correct tag target to post-receive hook when creating tag via UI
Fixes #24437
See merge request !7556
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 2470d504c68..72ac41f3472 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1354,6 +1354,28 @@ describe Repository, models: true do repository.add_tag(user, '8.5', 'master', 'foo') end + it 'does not create a tag when a pre-hook fails' do + allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) + + expect do + repository.add_tag(user, '8.5', 'master', 'foo') + end.to raise_error(GitHooksService::PreReceiveError) + + repository.expire_tags_cache + expect(repository.find_tag('8.5')).to be_nil + end + + it 'passes tag SHA to hooks' do + spy = GitHooksService.new + allow(GitHooksService).to receive(:new).and_return(spy) + allow(spy).to receive(:execute).and_call_original + + tag = repository.add_tag(user, '8.5', 'master', 'foo') + + expect(spy).to have_received(:execute). + with(anything, anything, anything, tag.target, anything) + end + it 'returns a Gitlab::Git::Tag object' do tag = repository.add_tag(user, '8.5', 'master', 'foo') |