diff --git a/lib/pact_broker/api/decorators/pact_decorator.rb b/lib/pact_broker/api/decorators/pact_decorator.rb index 00b4c8f0c..6530706dc 100644 --- a/lib/pact_broker/api/decorators/pact_decorator.rb +++ b/lib/pact_broker/api/decorators/pact_decorator.rb @@ -63,6 +63,13 @@ def to_hash(options = {}) } end + link :'pb:all-pact-versions' do | options | + { + title: "All versions of this pact", + href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url)) + } + end + link :'pb:latest-untagged-pact-version' do | options | { title: "Pact", diff --git a/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb index 0a17e2819..26c317839 100644 --- a/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb @@ -85,6 +85,11 @@ module Decorators expect(subject[:_links][:'pb:latest-pact-version'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest" end + it "includes a link to all pact versions" do + expect(subject[:_links][:'pb:all-pact-versions'][:title]).to eq "All versions of this pact" + expect(subject[:_links][:'pb:all-pact-versions'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/versions" + end + it "includes a link to the pact version" do expect(subject[:_links][:'pb:consumer-version'][:title]).to eq "Consumer version" expect(subject[:_links][:'pb:consumer-version'][:name]).to eq "1234"