Skip to content

Commit f0e37a4

Browse files
committed
fix: pass through includePendingStatus to the 'pacts for verification' API when it is false
1 parent 8e8bb22 commit f0e37a4

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

lib/pact/hash_refinements.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module Pact
2+
module HashRefinements
3+
refine Hash do
4+
def compact
5+
h = {}
6+
each do |key, value|
7+
h[key] = value unless value == nil
8+
end
9+
h
10+
end unless Hash.method_defined? :compact
11+
12+
def compact!
13+
reject! {|_key, value| value == nil}
14+
end unless Hash.method_defined? :compact!
15+
end
16+
end
17+
end

lib/pact/pact_broker/fetch_pact_uris_for_verification.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
require 'pact/pact_broker/fetch_pacts'
66
require 'pact/pact_broker/notices'
77
require 'pact/pact_broker/pact_selection_description'
8+
require "pact/hash_refinements"
89

910
module Pact
1011
module PactBroker
1112
class FetchPactURIsForVerification
13+
using Pact::HashRefinements
14+
1215
include PactSelectionDescription
1316
attr_reader :provider, :consumer_version_selectors, :provider_version_branch, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
1417

@@ -74,12 +77,12 @@ def pacts_for_verification_entity
7477

7578
def query
7679
q = {}
77-
q["includePendingStatus"] = true if options[:include_pending_status]
80+
q["includePendingStatus"] = options[:include_pending_status]
7881
q["consumerVersionSelectors"] = consumer_version_selectors if consumer_version_selectors.any?
7982
q["providerVersionTags"] = provider_version_tags if provider_version_tags.any?
80-
q["providerVersionBranch"] = provider_version_branch if provider_version_branch
81-
q["includeWipPactsSince"] = options[:include_wip_pacts_since] if options[:include_wip_pacts_since]
82-
q
83+
q["providerVersionBranch"] = provider_version_branch
84+
q["includeWipPactsSince"] = options[:include_wip_pacts_since]
85+
q.compact
8386
end
8487

8588
def extract_notices(pact)

0 commit comments

Comments
 (0)