Skip to content

Commit

Permalink
feat: correct logs relation to pb:logs in the triggered webhooks reso…
Browse files Browse the repository at this point in the history
…urce
  • Loading branch information
bethesque committed Jan 30, 2020
1 parent db1ed1e commit 89ea1a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion lib/pact_broker/api/decorators/triggered_webhook_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ 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",
name: represented.request_description
}
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]),
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/api/resources/triggered_webhook_logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89ea1a5

Please sign in to comment.