Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2015-12-01 08:22:45 +0300
committerRubén Dávila <ruben@gitlab.com>2015-12-03 17:39:15 +0300
commit338eb2c41ea766779d6bb7798079a1dd3a50e11d (patch)
treec643682f9670fcafb0660e8b1d531bf5a71b6072 /spec
parent5145706c82613d64462fe736850d09799224cd77 (diff)
Call update hook from new GitHooksService class. #3069
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb2
-rw-r--r--spec/services/git_hooks_service_spec.rb23
2 files changed, 18 insertions, 7 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index c746b8db621..fa261e64c35 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -107,7 +107,7 @@ describe Repository do
context 'when pre hooks were successful' do
it 'should run without errors' do
hook = double(trigger: true)
- expect(Gitlab::Git::Hook).to receive(:new).twice.and_return(hook)
+ expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
expect { repository.add_branch(user, 'new_feature', 'master') }.not_to raise_error
end
diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb
index 21585cc4629..bb639a5ae23 100644
--- a/spec/services/git_hooks_service_spec.rb
+++ b/spec/services/git_hooks_service_spec.rb
@@ -17,16 +17,17 @@ describe GitHooksService do
describe '#execute' do
- context 'when pre hooks were successful' do
- it 'should call post hooks' do
- expect(service).to receive(:run_hook).with('pre-receive').and_return(true)
- expect(service).to receive(:run_hook).with('post-receive').and_return(true)
+ context 'when receive hooks were successful' do
+ it 'should call post-receive hook' do
+ hook = double(trigger: true)
+ expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
+
expect(service.execute(user, @repo_path, @blankrev, @newrev, @ref) { }).to eq(true)
end
end
- context 'when pre hooks failed' do
- it 'should not call post hooks' do
+ context 'when pre-receive hook failed' do
+ it 'should not call post-receive hook' do
expect(service).to receive(:run_hook).with('pre-receive').and_return(false)
expect(service).not_to receive(:run_hook).with('post-receive')
@@ -34,5 +35,15 @@ describe GitHooksService do
end
end
+ context 'when update hook failed' do
+ it 'should not call post-receive hook' do
+ expect(service).to receive(:run_hook).with('pre-receive').and_return(true)
+ expect(service).to receive(:run_hook).with('update').and_return(false)
+ expect(service).not_to receive(:run_hook).with('post-receive')
+
+ service.execute(user, @repo_path, @blankrev, @newrev, @ref)
+ end
+ end
+
end
end