From c5c800f72cdfc12082a7fab3613f02c5c7c38a4d Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 1 Nov 2017 10:24:10 +1100 Subject: [PATCH] feat(matrix): update query to handle tag and latest flag --- lib/pact_broker/matrix/repository.rb | 5 +++-- spec/lib/pact_broker/matrix/repository_spec.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pact_broker/matrix/repository.rb b/lib/pact_broker/matrix/repository.rb index bdecfc43b..49f5905cd 100644 --- a/lib/pact_broker/matrix/repository.rb +++ b/lib/pact_broker/matrix/repository.rb @@ -59,8 +59,9 @@ def find_all selectors def look_up_versions_for_tags(selectors) selectors.collect do | selector | - if selector[:latest_tag] - version = version_repository.find_by_pacticpant_name_and_latest_tag(selector[:pacticipant_name], selector[:latest_tag]) + # resource validation currently stops tag being specified without latest=true + if selector[:tag] && selector[:latest] + version = version_repository.find_by_pacticpant_name_and_latest_tag(selector[:pacticipant_name], selector[:tag]) # validation in resource should ensure we always have a version { pacticipant_name: selector[:pacticipant_name], diff --git a/spec/lib/pact_broker/matrix/repository_spec.rb b/spec/lib/pact_broker/matrix/repository_spec.rb index 4a1d1050d..051003444 100644 --- a/spec/lib/pact_broker/matrix/repository_spec.rb +++ b/spec/lib/pact_broker/matrix/repository_spec.rb @@ -235,7 +235,7 @@ def build_selectors(hash) let(:selectors) do [ { pacticipant_name: "A", pacticipant_version_number: "1.2.3" }, - { pacticipant_name: "B", latest_tag: "prod" } + { pacticipant_name: "B", latest: true, tag: "prod" } ] end