diff --git a/lib/pact_broker/api/decorators/integration_decorator.rb b/lib/pact_broker/api/decorators/integration_decorator.rb index 446c9884c..e17654386 100644 --- a/lib/pact_broker/api/decorators/integration_decorator.rb +++ b/lib/pact_broker/api/decorators/integration_decorator.rb @@ -28,6 +28,12 @@ class IntegrationDecorator < BaseDecorator href: matrix_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url)) } end + + link "pb:group" do | options | + { + href: group_url(represented.consumer.name, options.fetch(:base_url)) + } + end end end end diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index cbdfc9014..63f4e96ff 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -212,6 +212,10 @@ def matrix_url_from_params params, base_url = '' matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url) end + def group_url(pacticipant_name, base_url = '') + "#{base_url}/groups/#{pacticipant_name}" + end + def hal_browser_url target_url "/hal-browser/browser.html#" + target_url end diff --git a/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb index 6564b42c0..e80749d6a 100644 --- a/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb @@ -8,6 +8,7 @@ module Decorators before do allow(integration_decorator).to receive(:dashboard_url_for_integration).and_return("/dashboard") allow(integration_decorator).to receive(:matrix_url).and_return("/matrix") + allow(integration_decorator).to receive(:group_url).and_return("/group") end let(:integration) do @@ -34,6 +35,9 @@ module Decorators "pb:matrix" => { "title" => "Matrix of pacts/verification results for the consumer and the provider", "href" => "/matrix" + }, + "pb:group" => { + "href" => "/group" } } } @@ -64,6 +68,14 @@ module Decorators ) subject end + + it "generates the correct group url for the matrix" do + expect(integration_decorator).to receive(:group_url).with( + "the consumer", + "http://example.org" + ) + subject + end end end end