Skip to content

Commit

Permalink
feat(matrix): update query to handle tag and latest flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 31, 2017
1 parent 0fa33f1 commit c5c800f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/pact_broker/matrix/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/pact_broker/matrix/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c5c800f

Please sign in to comment.