Skip to content

Commit

Permalink
fix(can-i-deploy): correctly construct options when environment is us…
Browse files Browse the repository at this point in the history
…ed in the can-i-deploy GET endpoint
  • Loading branch information
bethesque committed Jul 23, 2021
1 parent 76890ce commit cb79a40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/matrix/parse_can_i_deploy_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit cb79a40

Please sign in to comment.