Skip to content

Commit c5c800f

Browse files
committed
feat(matrix): update query to handle tag and latest flag
1 parent 0fa33f1 commit c5c800f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/pact_broker/matrix/repository.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def find_all selectors
5959

6060
def look_up_versions_for_tags(selectors)
6161
selectors.collect do | selector |
62-
if selector[:latest_tag]
63-
version = version_repository.find_by_pacticpant_name_and_latest_tag(selector[:pacticipant_name], selector[:latest_tag])
62+
# resource validation currently stops tag being specified without latest=true
63+
if selector[:tag] && selector[:latest]
64+
version = version_repository.find_by_pacticpant_name_and_latest_tag(selector[:pacticipant_name], selector[:tag])
6465
# validation in resource should ensure we always have a version
6566
{
6667
pacticipant_name: selector[:pacticipant_name],

spec/lib/pact_broker/matrix/repository_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def build_selectors(hash)
235235
let(:selectors) do
236236
[
237237
{ pacticipant_name: "A", pacticipant_version_number: "1.2.3" },
238-
{ pacticipant_name: "B", latest_tag: "prod" }
238+
{ pacticipant_name: "B", latest: true, tag: "prod" }
239239
]
240240
end
241241

0 commit comments

Comments
 (0)