Skip to content

Commit d5ea068

Browse files
committed
feat(pact resource): add link relation for all pact versions
1 parent 2d5f169 commit d5ea068

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/pact_broker/api/decorators/pact_decorator.rb

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ def to_hash(options = {})
6363
}
6464
end
6565

66+
link :'pb:all-pact-versions' do | options |
67+
{
68+
title: "All versions of this pact",
69+
href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
70+
}
71+
end
72+
6673
link :'pb:latest-untagged-pact-version' do | options |
6774
{
6875
title: "Pact",

spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ module Decorators
8585
expect(subject[:_links][:'pb:latest-pact-version'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest"
8686
end
8787

88+
it "includes a link to all pact versions" do
89+
expect(subject[:_links][:'pb:all-pact-versions'][:title]).to eq "All versions of this pact"
90+
expect(subject[:_links][:'pb:all-pact-versions'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/versions"
91+
end
92+
8893
it "includes a link to the pact version" do
8994
expect(subject[:_links][:'pb:consumer-version'][:title]).to eq "Consumer version"
9095
expect(subject[:_links][:'pb:consumer-version'][:name]).to eq "1234"

0 commit comments

Comments
 (0)