Skip to content

Commit 96769a8

Browse files
committed
feat(webhooks): add the logs and success flag to the execution result
1 parent cc14406 commit 96769a8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def body
6060
property :request, :extend => HTTPRequestDecorator
6161
property :response, :extend => HTTPResponseDecorator, if: lambda { |context| context[:options][:user_options][:show_response] }
6262
property :response_hidden_message, as: :message, exec_context: :decorator, if: lambda { |context| !context[:options][:user_options][:show_response] }
63+
property :logs
64+
property :success?, as: :success
6365

6466
link :webhook do | options |
6567
if options.fetch(:webhook).uuid

spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ module PactBroker
55
module Api
66
module Decorators
77
describe WebhookExecutionResultDecorator do
8-
98
describe "to_json" do
10-
11-
let(:webhook_execution_result) { PactBroker::Webhooks::WebhookExecutionResult.new(request, response, logs, error)}
9+
let(:webhook_execution_result) { PactBroker::Webhooks::WebhookExecutionResult.new(request, response, logs, error) }
1210
let(:logs) { "logs" }
1311
let(:headers) { { "Something" => ["blah", "thing"]} }
1412
let(:request) do
@@ -34,6 +32,14 @@ module Decorators
3432
expect(subject[:_links][:'try-again'][:href]).to eq 'http://resource-url'
3533
end
3634

35+
it "includes a success flag" do
36+
expect(subject[:success]).to be true
37+
end
38+
39+
it "includes the logs" do
40+
expect(subject[:logs]).to eq logs
41+
end
42+
3743
context "when there is a uuid" do
3844
it "include a link to the webhook" do
3945
expect(subject[:_links][:webhook][:href]).to eq 'http://example.org/webhooks/some-uuid'
@@ -48,7 +54,6 @@ module Decorators
4854
end
4955
end
5056

51-
5257
context "when there is an error" do
5358
let(:error) { double('error', message: 'message', backtrace: ['blah','blah']) }
5459

0 commit comments

Comments
 (0)