summaryrefslogtreecommitdiff
path: root/spec/gitlab_custom_hook_spec.rb
blob: f93c8b44e95db74aebc191d6b0302ecc7e55b51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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