diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index 742eb9088..950c3e2bd 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -117,7 +117,7 @@ def webhook_execution_url webhook, base_url "#{base_url}/webhooks/#{webhook.uuid}/execute" end - def webhooks_for_pact_url consumer, provider, base_url + def webhooks_for_pact_url consumer, provider, base_url = '' "#{base_url}/webhooks/provider/#{url_encode(provider.name)}/consumer/#{url_encode(consumer.name)}" end diff --git a/lib/pact_broker/ui/view_models/relationship.rb b/lib/pact_broker/ui/view_models/relationship.rb index 313cedb3c..a8bb28480 100644 --- a/lib/pact_broker/ui/view_models/relationship.rb +++ b/lib/pact_broker/ui/view_models/relationship.rb @@ -60,7 +60,12 @@ def webhook_last_execution_date end def webhook_url - url = PactBroker::Api::PactBrokerUrls.webhooks_status_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider + url = case @relationship.webhook_status + when :none + PactBroker::Api::PactBrokerUrls.webhooks_for_pact_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider + else + PactBroker::Api::PactBrokerUrls.webhooks_status_url @relationship.latest_pact.consumer, @relationship.latest_pact.provider + end "/hal-browser/browser.html##{url}" end diff --git a/spec/lib/pact_broker/ui/view_models/relationship_spec.rb b/spec/lib/pact_broker/ui/view_models/relationship_spec.rb index cdf702f6e..e0fbc62d4 100644 --- a/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +++ b/spec/lib/pact_broker/ui/view_models/relationship_spec.rb @@ -77,14 +77,14 @@ module ViewDomain context "when the webhooks_status is :none" do its(:webhook_label) { is_expected.to eq "Create" } its(:webhook_status) { is_expected.to eq "" } - its(:webhook_url) { is_expected.to include "/webhooks/provider/Provider%20Name/consumer/Consumer%20Name/status"} + its(:webhook_url) { is_expected.to end_with "/webhooks/provider/Provider%20Name/consumer/Consumer%20Name"} end context "when the webhooks_status is :success" do let(:webhook_status) { :success } its(:webhook_label) { is_expected.to eq "1 day ago" } its(:webhook_status) { is_expected.to eq "success" } - its(:webhook_url) { is_expected.to include "/webhooks/provider/Provider%20Name/consumer/Consumer%20Name/status"} + its(:webhook_url) { is_expected.to end_with "/webhooks/provider/Provider%20Name/consumer/Consumer%20Name/status"} end context "when the webhooks_status is :failure" do