From 89ea1a58ce8572449c6b5a6dc87be25979f7ff61 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 30 Jan 2020 14:45:33 +1100 Subject: [PATCH] feat: correct logs relation to pb:logs in the triggered webhooks resource --- .../api/decorators/triggered_webhook_decorator.rb | 10 +++++++++- .../api/resources/triggered_webhook_logs.rb | 2 +- .../api/decorators/triggered_webhook_decorator_spec.rb | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb b/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb index 4539268d9..e2c60d485 100644 --- a/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb +++ b/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb @@ -12,7 +12,7 @@ class TriggeredWebhookDecorator < BaseDecorator property :created_at, as: :triggeredAt - link :logs do | context | + link :'pb:logs' do | context | { href: triggered_webhook_logs_url(represented, context[:base_url]), title: "Webhook execution logs", @@ -20,6 +20,14 @@ class TriggeredWebhookDecorator < BaseDecorator } end + link :logs do | context | + { + href: triggered_webhook_logs_url(represented, context[:base_url]), + title: "DEPRECATED - Use pb:logs", + name: represented.request_description + } + end + link :'pb:webhook' do | context | { href: webhook_url(represented.webhook_uuid, context[:base_url]), diff --git a/lib/pact_broker/api/resources/triggered_webhook_logs.rb b/lib/pact_broker/api/resources/triggered_webhook_logs.rb index 804a19f8f..1fa351b09 100644 --- a/lib/pact_broker/api/resources/triggered_webhook_logs.rb +++ b/lib/pact_broker/api/resources/triggered_webhook_logs.rb @@ -26,7 +26,7 @@ def to_text def triggered_webhook @triggered_webhook ||= begin - criteria = {webhook_uuid: identifier_from_path[:uuid], trigger_uuid: identifier_from_path[:trigger_uuid]} + criteria = { webhook_uuid: identifier_from_path[:uuid], trigger_uuid: identifier_from_path[:trigger_uuid] } PactBroker::Webhooks::TriggeredWebhook.where(criteria).single_record end end diff --git a/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb index 51641398c..ca6af20dd 100644 --- a/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb @@ -43,7 +43,7 @@ module Decorators subject { JSON.parse(json, symbolize_names: true) } it "includes a link to the logs" do - expect(subject[:_links][:logs][:href]).to eq logs_url + expect(subject[:_links][:'pb:logs'][:href]).to eq logs_url end it "includes a link to the webhook" do