Skip to content

Commit

Permalink
fix(can-i-deploy): if only one selector is specified and no --to TAG …
Browse files Browse the repository at this point in the history
…is specified, set latest=true for automatically calculated dependencies
  • Loading branch information
bethesque committed Feb 12, 2020
1 parent f72e63f commit 045fa91
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/pacts/markdown/Pact Broker Client - Pact Broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ Given **the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 an
{
"method": "get",
"path": "/matrix",
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp"
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp&latest=true"
}
```
Pact Broker will respond with:
Expand Down
6 changes: 4 additions & 2 deletions lib/pact_broker/client/matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def get selectors, options = {}
query = {
q: convert_selector_hashes_to_params(selectors),
latestby: latestby
}.merge(query_options(options))
}.merge(query_options(options, selectors))
response = self.class.get("/matrix", query: query, headers: default_get_headers)
response = handle_response(response) do
Matrix::Resource.new(JSON.parse(response.body, symbolize_names: true))
Expand Down Expand Up @@ -41,7 +41,7 @@ def handle_response response
end
end

def query_options(options)
def query_options(options, selectors)
opts = {}
if options.key?(:success)
opts[:success] = [*options[:success]]
Expand All @@ -50,6 +50,8 @@ def query_options(options)
if options[:to_tag]
opts[:latest] = 'true'
opts[:tag] = options[:to_tag]
elsif selectors.size == 1
opts[:latest] = 'true'
end
opts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/pacts/pact_broker_client-pact_broker.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
"request": {
"method": "get",
"path": "/matrix",
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp"
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp&latest=true"
},
"response": {
"status": 200,
Expand Down
2 changes: 1 addition & 1 deletion spec/service_providers/pact_broker_client_matrix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module PactBroker::Client
with(
method: :get,
path: "/matrix",
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp"
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp&latest=true"
).
will_respond_with(
status: 200,
Expand Down

0 comments on commit 045fa91

Please sign in to comment.