Skip to content
Snippets Groups Projects
Commit 338eb2c4 authored by Rubén Dávila's avatar Rubén Dávila
Browse files

Call update hook from new GitHooksService class. #3069

parent 5145706c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -8,9 +8,7 @@ class GitHooksService
@newrev = newrev
@ref = ref
 
pre_status = run_hook('pre-receive')
if pre_status
if run_hook('pre-receive') && run_hook('update')
yield
 
run_hook('post-receive')
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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')
 
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment