diff --git a/lib/pact_broker/matrix/deployment_status_summary.rb b/lib/pact_broker/matrix/deployment_status_summary.rb index b3d9be16c..985d97ab5 100644 --- a/lib/pact_broker/matrix/deployment_status_summary.rb +++ b/lib/pact_broker/matrix/deployment_status_summary.rb @@ -75,11 +75,15 @@ def bad_practice_warnings def selector_without_pacticipant_version_number_specified? # If only the pacticipant name is specified, it can't be a can-i-deploy query, must be a matrix UI query - resolved_selectors - .select(&:specified?) - .reject(&:only_pacticipant_name_specified?) - .reject(&:pacticipant_version_specified_in_original_selector?) - .any? + if resolved_selectors.select(&:specified?).reject(&:only_pacticipant_name_specified?).any? + # There should be at least one selector with a version number specified + resolved_selectors + .select(&:specified?) + .select(&:pacticipant_version_specified_in_original_selector?) + .empty? + else + false + end end diff --git a/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb b/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb index 9a94139bc..59d920f73 100644 --- a/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +++ b/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb @@ -273,7 +273,7 @@ module Matrix its(:reasons) { is_expected.to eq [IgnoreSelectorDoesNotExist.new(resolved_ignore_selectors.first), PactBroker::Matrix::Successful.new] } end - context "when there is a selector without a specified pacticipant version number" do + context "when there are no specified selectors with a pacticipant version number" do let(:resolved_selectors) do [ ResolvedSelector.new( @@ -290,6 +290,31 @@ module Matrix its(:reasons) { is_expected.to include SelectorWithoutPacticipantVersionNumberSpecified.new } end + context "when there are only pacticipant names specified" do + let(:resolved_selectors) do + [ + ResolvedSelector.new( + pacticipant_id: foo.id, + pacticipant_name: foo.name, + pacticipant_version_number: nil, + pacticipant_version_id: nil, + type: :specified, + original_selector: { pacticipant_name: foo.name } + ), + ResolvedSelector.new( + pacticipant_id: bar.id, + pacticipant_name: bar.name, + pacticipant_version_number: nil, + pacticipant_version_id: nil, + type: :specified, + original_selector: { pacticipant_name: bar.name } + ) + ] + end + + its(:reasons) { is_expected.to_not include SelectorWithoutPacticipantVersionNumberSpecified.new } + end + context "when there is no to tag or environment specified and there was only one specified selector" do let(:resolved_selectors) do [