diff options
author | Rémy Coutable <remy@rymai.me> | 2019-06-18 18:20:33 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-06-18 18:20:33 +0300 |
commit | 0eae158c15eb047a58a3f51db0c32f1b841b4b60 (patch) | |
tree | ce01e8e7efa4c3f336ff9f856918932cffa175ab /spec | |
parent | cd17f804d51751870f71e3bab57feeb9ab75da38 (diff) | |
parent | b2c73fde791ebac6c2cc615fce19294190b05609 (diff) |
Merge branch '59257-find-new-branches-harder' into 'master'
Look for new branches more carefully
Closes #59257
See merge request gitlab-org/gitlab-ce!29761
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/git/branch_hooks_service_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/services/git/branch_hooks_service_spec.rb b/spec/services/git/branch_hooks_service_spec.rb index b5694628269..23be400059e 100644 --- a/spec/services/git/branch_hooks_service_spec.rb +++ b/spec/services/git/branch_hooks_service_spec.rb @@ -344,4 +344,38 @@ describe Git::BranchHooksService do end end end + + describe 'New branch detection' do + let(:branch) { 'fix' } + + context 'oldrev is the blank SHA' do + let(:oldrev) { Gitlab::Git::BLANK_SHA } + + it 'is treated as a new branch' do + expect(service).to receive(:branch_create_hooks) + + service.execute + end + end + + context 'oldrev is set' do + context 'Gitaly does not know about the branch' do + it 'is treated as a new branch' do + allow(project.repository).to receive(:branch_names) { [] } + + expect(service).to receive(:branch_create_hooks) + + service.execute + end + end + + context 'Gitaly knows about the branch' do + it 'is not treated as a new branch' do + expect(service).not_to receive(:branch_create_hooks) + + service.execute + end + end + end + end end |