diff --git a/lib/pact_broker/matrix/parse_can_i_deploy_query.rb b/lib/pact_broker/matrix/parse_can_i_deploy_query.rb index 155a71f5f..e5fa71f48 100644 --- a/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +++ b/lib/pact_broker/matrix/parse_can_i_deploy_query.rb @@ -8,8 +8,7 @@ class ParseCanIDeployQuery def self.call params selector = PactBroker::Matrix::UnresolvedSelector.new options = { - latestby: "cvp", - latest: true + latestby: "cvp" } if params[:pacticipant].is_a?(String) @@ -22,6 +21,7 @@ def self.call params if params[:to].is_a?(String) options[:tag] = params[:to] + options[:latest] = true end if params[:environment].is_a?(String) diff --git a/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb b/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb index 9c52bf47a..c2f83173f 100644 --- a/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +++ b/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb @@ -21,7 +21,8 @@ module Matrix subject { parsed_options } its([:latestby]) { is_expected.to eq "cvp" } - its([:latest]) { is_expected.to eq true } + its([:latest]) { is_expected.to eq nil } + its([:environment_name]) { is_expected.to eq "prod" } its([:ignore_selectors]) { is_expected.to eq [] } context "with pacticipants to ignore" do @@ -36,6 +37,20 @@ module Matrix ] end end + + context "with a tag" do + let(:params) do + { + pacticipant: "foo", + version: "1", + to: "prod" + } + end + + its([:latestby]) { is_expected.to eq "cvp" } + its([:latest]) { is_expected.to eq true } + its([:tag]) { is_expected.to eq "prod" } + end end describe "parsed_selectors" do