Commit b9141ad9 authored by Tom Quirk's avatar Tom Quirk

Fix hook log path for service hooks

Web hooks for integrations (fka services) have a logs
table, and the links to individual logs was broken.
This bug was introduced in MR 71792.

This commit fixes the issue by updating the
hook_log_path helper to support ServiceHook
hook type.

Changelog: fixed
parent 77a3516e
......@@ -39,7 +39,7 @@ module HooksHelper
def hook_log_path(hook, hook_log)
case hook
when ProjectHook
when ProjectHook, ServiceHook
hook_log.present.details_path
when SystemHook
admin_hook_hook_log_path(hook, hook_log)
......
......@@ -4,7 +4,10 @@ require 'spec_helper'
RSpec.describe HooksHelper do
let(:project) { create(:project) }
let(:integration) { create(:drone_ci_integration, project: project) }
let(:project_hook) { create(:project_hook, project: project) }
let(:service_hook) { create(:service_hook, integration: integration) }
let(:system_hook) { create(:system_hook) }
describe '#link_to_test_hook' do
......@@ -31,6 +34,15 @@ RSpec.describe HooksHelper do
end
end
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
context 'with a system hook' do
let(:web_hook_log) { create(:web_hook_log, web_hook: system_hook) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment