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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe HooksHelper do
let(:project) { build_stubbed(:project) }
let(:project_hook) { build_stubbed(:project_hook, project: project) }
let(:service_hook) { build_stubbed(:service_hook, integration: build_stubbed(:drone_ci_integration)) }
let(:system_hook) { build_stubbed(:system_hook) }
describe '#webhook_form_data' do
subject { helper.webhook_form_data(project_hook) }
context 'when there are no URL variables' do
it 'returns proper data' do
expect(subject).to match(
url: project_hook.url,
url_variables: Gitlab::Json.dump([])
)
end
end
context 'when there are URL variables' do
let(:project_hook) { build_stubbed(:project_hook, :url_variables, project: project) }
it 'returns proper data' do
expect(subject).to match(
url: project_hook.url,
url_variables: Gitlab::Json.dump(['abc'])
)
end
end
end
describe '#link_to_test_hook' do
let(:trigger) { 'push_events' }
it 'returns project namespaced link' do
expect(helper.link_to_test_hook(project_hook, trigger))
.to include("href=\"#{test_project_hook_path(project, project_hook, trigger: trigger)}\"")
end
it 'returns admin namespaced link' do
expect(helper.link_to_test_hook(system_hook, trigger))
.to include("href=\"#{test_admin_hook_path(system_hook, trigger: trigger)}\"")
end
end
describe '#hook_log_path' do
context 'with a project hook' do
let(:web_hook_log) { build_stubbed(:web_hook_log, web_hook: project_hook) }
it 'returns project-namespaced link' do
expect(helper.hook_log_path(project_hook, web_hook_log))
.to eq(web_hook_log.present.details_path)
end
end
context 'with a service hook' do
let(:web_hook_log) { build_stubbed(:web_hook_log, web_hook: service_hook) }
it 'returns project-namespaced link' do
expect(helper.hook_log_path(project_hook, web_hook_log))
.to eq(web_hook_log.present.details_path)
end
end
context 'with a system hook' do
let(:web_hook_log) { build_stubbed(:web_hook_log, web_hook: system_hook) }
it 'returns admin-namespaced link' do
expect(helper.hook_log_path(system_hook, web_hook_log))
.to eq(admin_hook_hook_log_path(system_hook, web_hook_log))
end
end
end
end
|