2019-09-30 08:06:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe HooksHelper do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-07-20 11:12:06 -04:00
|
|
|
let(:project_hook) { create(:project_hook, project: project) }
|
2022-01-10 19:13:53 -05:00
|
|
|
let(:service_hook) { create(:service_hook, integration: create(:drone_ci_integration)) }
|
2017-07-20 11:12:06 -04:00
|
|
|
let(:system_hook) { create(:system_hook) }
|
|
|
|
|
|
|
|
describe '#link_to_test_hook' do
|
2021-10-11 08:11:56 -04:00
|
|
|
let(:trigger) { 'push_events' }
|
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
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
|
2021-10-11 08:11:56 -04:00
|
|
|
|
|
|
|
describe '#hook_log_path' do
|
|
|
|
context 'with a project hook' do
|
|
|
|
let(:web_hook_log) { create(: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
|
|
|
|
|
2022-01-10 19:13:53 -05:00
|
|
|
context 'with a service hook' do
|
|
|
|
let(:web_hook_log) { create(: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
|
|
|
|
|
2021-10-11 08:11:56 -04:00
|
|
|
context 'with a system hook' do
|
|
|
|
let(:web_hook_log) { create(: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
|
2017-07-20 11:12:06 -04:00
|
|
|
end
|