Skip to content

Commit

Permalink
feat(webhooks): add the logs and success flag to the execution result
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 30, 2019
1 parent cc14406 commit 96769a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def body
property :request, :extend => HTTPRequestDecorator
property :response, :extend => HTTPResponseDecorator, if: lambda { |context| context[:options][:user_options][:show_response] }
property :response_hidden_message, as: :message, exec_context: :decorator, if: lambda { |context| !context[:options][:user_options][:show_response] }
property :logs
property :success?, as: :success

link :webhook do | options |
if options.fetch(:webhook).uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ module PactBroker
module Api
module Decorators
describe WebhookExecutionResultDecorator do

describe "to_json" do

let(:webhook_execution_result) { PactBroker::Webhooks::WebhookExecutionResult.new(request, response, logs, error)}
let(:webhook_execution_result) { PactBroker::Webhooks::WebhookExecutionResult.new(request, response, logs, error) }
let(:logs) { "logs" }
let(:headers) { { "Something" => ["blah", "thing"]} }
let(:request) do
Expand All @@ -34,6 +32,14 @@ module Decorators
expect(subject[:_links][:'try-again'][:href]).to eq 'http://resource-url'
end

it "includes a success flag" do
expect(subject[:success]).to be true
end

it "includes the logs" do
expect(subject[:logs]).to eq logs
end

context "when there is a uuid" do
it "include a link to the webhook" do
expect(subject[:_links][:webhook][:href]).to eq 'http://example.org/webhooks/some-uuid'
Expand All @@ -48,7 +54,6 @@ module Decorators
end
end


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

Expand Down

0 comments on commit 96769a8

Please sign in to comment.