Skip to content

Commit

Permalink
feat(pact resource): add link relation for all pact versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 14, 2017
1 parent 2d5f169 commit d5ea068
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pact_broker/api/decorators/pact_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d5ea068

Please sign in to comment.