summaryrefslogtreecommitdiff
path: root/spec/gitlab_custom_hook_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/gitlab_custom_hook_spec.rb')
-rw-r--r--spec/gitlab_custom_hook_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/gitlab_custom_hook_spec.rb b/spec/gitlab_custom_hook_spec.rb
new file mode 100644
index 0000000..f93c8b4
--- /dev/null
+++ b/spec/gitlab_custom_hook_spec.rb
@@ -0,0 +1,33 @@
+# coding: utf-8
+require 'spec_helper'
+require 'pry'
+require 'gitlab_custom_hook'
+
+describe GitlabCustomHook do
+ let(:gitlab_custom_hook) { GitlabCustomHook.new('key_1') }
+ let(:hook_path) { File.join(ROOT_PATH, 'spec/support/gl_id_test_hook') }
+
+ context 'pre_receive hook' do
+ it 'passes GL_ID variable to hook' do
+ allow(gitlab_custom_hook).to receive(:hook_file).and_return(hook_path)
+
+ expect(gitlab_custom_hook.pre_receive('changes', 'repo_path')).to be_true
+ end
+ end
+
+ context 'post_receive hook' do
+ it 'passes GL_ID variable to hook' do
+ allow(gitlab_custom_hook).to receive(:hook_file).and_return(hook_path)
+
+ expect(gitlab_custom_hook.post_receive('changes', 'repo_path')).to be_true
+ end
+ end
+
+ context 'update hook' do
+ it 'passes GL_ID variable to hook' do
+ allow(gitlab_custom_hook).to receive(:hook_file).and_return(hook_path)
+
+ expect(gitlab_custom_hook.update('master', '', '', 'repo_path')).to be_true
+ end
+ end
+end