diff options
| author | Rubén Dávila <ruben@gitlab.com> | 2015-11-25 19:20:40 -0500 |
|---|---|---|
| committer | Rubén Dávila <ruben@gitlab.com> | 2015-12-03 09:39:15 -0500 |
| commit | 5145706c82613d64462fe736850d09799224cd77 (patch) | |
| tree | 81744d6a01be18d3c89c6cb726f8496777b99e4e /spec/services | |
| parent | b5103a83a8574936721250997e75ab9a6855d00a (diff) | |
| download | gitlab-ce-5145706c82613d64462fe736850d09799224cd77.tar.gz | |
Run custom Git hooks when creating or deleting branches through the UI. #1156
Diffstat (limited to 'spec/services')
| -rw-r--r-- | spec/services/git_hooks_service_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb new file mode 100644 index 00000000000..21585cc4629 --- /dev/null +++ b/spec/services/git_hooks_service_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe GitHooksService do + include RepoHelpers + + let(:user) { create :user } + let(:project) { create :project } + let(:service) { GitHooksService.new } + + before do + @blankrev = Gitlab::Git::BLANK_SHA + @oldrev = sample_commit.parent_id + @newrev = sample_commit.id + @ref = 'refs/heads/feature' + @repo_path = project.repository.path_to_repo + end + + 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) + 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 + expect(service).to receive(:run_hook).with('pre-receive').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 |
