Skip to content

Commit

Permalink
feat(webhook status): use pact webhooks URL for Create link on status…
Browse files Browse the repository at this point in the history
… page
  • Loading branch information
bethesque committed Sep 11, 2017
1 parent 9c3694e commit 056c77d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion lib/pact_broker/ui/view_models/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact_broker/ui/view_models/relationship_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 056c77d

Please sign in to comment.