From eda8cbfd9cf9c4fae52bca9582c5876fb091656f Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 27 Jun 2018 21:14:05 +1000 Subject: [PATCH] feat: deprecate provider relation in provider pacts resource in preference for pb:provider --- .../api/decorators/provider_pacts_decorator.rb | 12 ++++++++++-- .../api/decorators/provider_pacts_decorator_spec.rb | 9 +++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/pact_broker/api/decorators/provider_pacts_decorator.rb b/lib/pact_broker/api/decorators/provider_pacts_decorator.rb index 4c8056189..30ad076f0 100644 --- a/lib/pact_broker/api/decorators/provider_pacts_decorator.rb +++ b/lib/pact_broker/api/decorators/provider_pacts_decorator.rb @@ -14,10 +14,10 @@ class ProviderPactsDecorator < BaseDecorator } end - link :provider do | context | + link :'pb:provider' do | context | { href: pacticipant_url(context[:base_url], OpenStruct.new(name: context[:provider_name])), - title: context[:provider_name] + name: context[:provider_name] } end @@ -32,6 +32,14 @@ class ProviderPactsDecorator < BaseDecorator end end + link :provider do | context | + { + href: pacticipant_url(context[:base_url], OpenStruct.new(name: context[:provider_name])), + title: context[:provider_name], + name: "DEPRECATED - please use the pb:provider relation" + } + end + links :'pacts' do | context | represented.collect do | pact | { diff --git a/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb index d8be5979e..89f4e2caf 100644 --- a/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb @@ -13,7 +13,8 @@ module Decorators { base_url: 'http://example.org', resource_url: 'http://example.org/provider-pacts', - title: 'title' + title: 'title', + provider_name: 'foo' } end @@ -30,9 +31,9 @@ module Decorators :href=> "http://example.org/provider-pacts", :title => "title" }, - :provider => { - :href => "http://example.org/pacticipants/", - :title => nil + :"pb:provider" => { + :href => "http://example.org/pacticipants/foo", + :name => "foo" }, :"pb:pacts" =>[{ :href => "pact_url",