Skip to content

Commit

Permalink
feat: update pacts relation name in retrieve pacts query
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed May 1, 2018
1 parent c23731e commit 7d965bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doc/pacts/markdown/Pact Broker Client - Pact Broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ Pact Broker will respond with:
"href": "http://example.org/pacticipants/Pricing%20Service",
"title": "Pricing Service"
},
"pacts": [
"pb:pacts": [
{
"href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
"title": "Pact between Condor (v1.3.0) and Pricing Service",
Expand Down Expand Up @@ -521,7 +521,7 @@ Pact Broker will respond with:
"href": "http://example.org/pacticipants/Pricing%20Service",
"title": "Pricing Service"
},
"pacts": [
"pb:pacts": [
{
"href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
"title": "Pact between Condor (v1.3.0) and Pricing Service",
Expand Down
8 changes: 7 additions & 1 deletion lib/pact_broker/client/pacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def list_latest_for_provider options
url = get_latest_provider_contracts(options)
response = self.class.get(url, headers: {})
handle_response(response) do
map_latest_provider_pacts_to_hash JSON.parse(response.body)["_links"]["pacts"]
map_latest_provider_pacts_to_hash(pact_links(response))
end
end

Expand All @@ -63,6 +63,12 @@ def latest options

private

def pact_links response
body = JSON.parse(response.body)
# pacts relation is deprecated
body["_links"]["pb:pacts"] || body["_links"]["pacts"]
end

#TODO Move into mapper class
def map_pact_list_to_hash pacts_list
pacts_list.collect do | pact_hash |
Expand Down
4 changes: 2 additions & 2 deletions spec/pacts/pact_broker_client-pact_broker.json
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@
"href": "http://example.org/pacticipants/Pricing%20Service",
"title": "Pricing Service"
},
"pacts": [
"pb:pacts": [
{
"href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
"title": "Pact between Condor (v1.3.0) and Pricing Service",
Expand Down Expand Up @@ -896,7 +896,7 @@
"href": "http://example.org/pacticipants/Pricing%20Service",
"title": "Pricing Service"
},
"pacts": [
"pb:pacts": [
{
"href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
"title": "Pact between Condor (v1.3.0) and Pricing Service",
Expand Down
2 changes: 1 addition & 1 deletion spec/support/latest_pacts_for_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"href": "http://example.org/pacticipants/Pricing%20Service",
"title": "Pricing Service"
},
"pacts": [
"pb:pacts": [
{
"href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
"title": "Pact between Condor (v1.3.0) and Pricing Service",
Expand Down

0 comments on commit 7d965bf

Please sign in to comment.