lib/pact_broker/matrix/service.rb in pact_broker-2.12.0 vs lib/pact_broker/matrix/service.rb in pact_broker-2.13.0

- old
+ new

@@ -14,20 +14,38 @@ def find_for_consumer_and_provider params matrix_repository.find_for_consumer_and_provider params[:consumer_name], params[:provider_name] end + def find_for_consumer_and_provider_with_tags params + consumer_criteria = { + pacticipant_name: params[:consumer_name], + tag: params[:tag], + latest: true + } + provider_criteria = { + pacticipant_name: params[:provider_name], + tag: params[:provider_tag], + latest: true + } + selectors = [consumer_criteria, provider_criteria] + options = { latestby: 'cvpv' } + if validate_selectors(selectors).empty? + matrix_repository.find(selectors, options).first + else + nil + end + end + def find_compatible_pacticipant_versions criteria matrix_repository.find_compatible_pacticipant_versions criteria end def validate_selectors selectors error_messages = [] selectors.each do | s | - if s[:pacticipant_name].nil? && s[:pacticipant_version_number].nil? - error_messages << "Please specify the pacticipant name and version" - elsif s[:pacticipant_name].nil? + if s[:pacticipant_name].nil? error_messages << "Please specify the pacticipant name" else if s.key?(:pacticipant_version_number) && s.key?(:latest) error_messages << "A version and latest flag cannot both be specified for #{s[:pacticipant_name]}" end