From 1e6a06a0baba53c7e80a7eb2f7d1bf1913ef2491 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 16 Oct 2020 08:21:43 +1100 Subject: [PATCH] fix: typo when rendering created webhook for old webhooks path Fixes: https://github.com/pact-foundation/pact_broker/issues/356 --- lib/pact_broker/api/resources/pact_webhooks.rb | 2 +- spec/features/create_webhook_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/api/resources/pact_webhooks.rb b/lib/pact_broker/api/resources/pact_webhooks.rb index 1e0acd80e..5220cbc3c 100644 --- a/lib/pact_broker/api/resources/pact_webhooks.rb +++ b/lib/pact_broker/api/resources/pact_webhooks.rb @@ -52,7 +52,7 @@ def post_is_create? def from_json saved_webhook = webhook_service.create next_uuid, webhook, consumer, provider - response.body = Decorators::WebhookDecorator.new(saved_webhook).to_json(decoractor_options) + response.body = Decorators::WebhookDecorator.new(saved_webhook).to_json(decorator_options) end def to_json diff --git a/spec/features/create_webhook_spec.rb b/spec/features/create_webhook_spec.rb index d2fbe2e3b..71a91fa9d 100644 --- a/spec/features/create_webhook_spec.rb +++ b/spec/features/create_webhook_spec.rb @@ -123,4 +123,22 @@ expect(PactBroker::Webhooks::Webhook.first.provider).to_not be nil end end + + context "with the old path" do + let(:path) { "/pacts/provider/Some%20Provider/consumer/Some%20Consumer/webhooks" } + + its(:status) { is_expected.to be 201 } + + it "returns the Location header" do + expect(subject.headers['Location']).to match(%r{http://example.org/webhooks/.+}) + end + + it "returns a JSON Content Type" do + expect(subject.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' + end + + it "returns the newly created webhook" do + expect(response_body).to include webhook_hash + end + end end