diff --git a/lib/pact_broker/api/decorators/matrix_decorator.rb b/lib/pact_broker/api/decorators/matrix_decorator.rb index c132f9f71..7a642894f 100644 --- a/lib/pact_broker/api/decorators/matrix_decorator.rb +++ b/lib/pact_broker/api/decorators/matrix_decorator.rb @@ -76,7 +76,7 @@ def consumer_hash(line, consumer, consumer_version, base_url) href: version_url(base_url, consumer_version) } }, - tags: tags(line.consumer_version_tags) + tags: tags(line.consumer_version_tags, base_url) }, _links: { self: { @@ -86,11 +86,16 @@ def consumer_hash(line, consumer, consumer_version, base_url) } end - def tags(tags) + def tags(tags, base_url) tags.collect do | tag | { name: tag.name, - latest: tag.latest? + latest: tag.latest?, + _links: { + self: { + href: tag_url(base_url, tag) + } + } } end end @@ -114,7 +119,7 @@ def provider_hash(line, provider, provider_version, base_url) href: version_url(base_url, provider_version) } }, - tags: tags(line.provider_version_tags) + tags: tags(line.provider_version_tags, base_url) } end diff --git a/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb index 127d206f0..f67b37cb4 100644 --- a/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb @@ -66,8 +66,12 @@ module Decorators tags: [ { name: 'prod', - latest: true - + latest: true, + _links: { + self: { + href: 'http://example.org/pacticipants/Consumer/versions/1.0.0/tags/prod' + } + } } ] } @@ -92,10 +96,14 @@ module Decorators tags: [ { name: 'master', - latest: false + latest: false, + _links: { + self: { + href: 'http://example.org/pacticipants/Provider/versions/4.5.6/tags/master' + } + } } ] - } } end @@ -123,15 +131,19 @@ module Decorators } end + let(:consumer_version) { double("consumer version", number: "1.0.0", pacticipant: double("consumer", name: "Consumer")) } + let(:consumer_version_tags) do [ - double('tag', name: 'prod', latest?: true) + double("tag", name: "prod", latest?: true, version: consumer_version) ] end + let(:provider_version) { double("provider version", number: "4.5.6", pacticipant: double("provider", name: "Provider")) } + let(:provider_version_tags) do [ - double('tag', name: 'master', latest?: false) + double("tag", name: "master", latest?: false, version: provider_version) ] end @@ -158,11 +170,11 @@ module Decorators let(:parsed_json) { JSON.parse(json, symbolize_names: true) } it "includes the consumer details" do - expect(parsed_json[:matrix][0][:consumer]).to eq consumer_hash + expect(parsed_json[:matrix][0][:consumer]).to match_pact consumer_hash end it "includes the provider details" do - expect(parsed_json[:matrix][0][:provider]).to eq provider_hash + expect(parsed_json[:matrix][0][:provider]).to match_pact provider_hash end it "includes the verification details" do