Skip to content

Commit 23b02c8

Browse files
committed
feat(pact ui): update matrix URL to specify the latest provider version
1 parent 99b36d5 commit 23b02c8

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

lib/pact_broker/api/pact_broker_urls.rb

+11
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ def matrix_for_pacticipant_version_url(version, base_url = '')
261261
"#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}"
262262
end
263263

264+
def matrix_for_pact_url(pact, base_url = '')
265+
query = {
266+
q: [
267+
{ pacticipant: pact.consumer_name, version: pact.consumer_version_number },
268+
{ pacticipant: pact.provider_name, latest: true }
269+
],
270+
latestby: 'cvpv'
271+
}
272+
"#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}"
273+
end
274+
264275
def matrix_url_from_params params, base_url = ''
265276
matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url)
266277
end

lib/pact_broker/api/renderers/html_pact_renderer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def pact_url
137137
end
138138

139139
def matrix_url
140-
PactBroker::Api::PactBrokerUrls.matrix_for_pacticipant_version_url(@pact.consumer_version, base_url)
140+
PactBroker::Api::PactBrokerUrls.matrix_for_pact_url(@pact, base_url)
141141
end
142142

143143
def latest_pact_url

spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Renderers
1212
ENV['TZ'] = "Australia/Melbourne"
1313
PactBroker.configuration.enable_public_badge_access = true
1414
allow(PactBroker::Api::PactBrokerUrls).to receive(:pact_url).with('http://base', pact).and_return(pact_url)
15-
allow(PactBroker::Api::PactBrokerUrls).to receive(:matrix_for_pacticipant_version_url).with(consumer_version, 'http://base').and_return(matrix_url)
15+
allow(PactBroker::Api::PactBrokerUrls).to receive(:matrix_for_pact_url).with(pact, 'http://base').and_return(matrix_url)
1616
allow_any_instance_of(HtmlPactRenderer).to receive(:logger).and_return(logger)
1717

1818
Timecop.freeze(created_at + 3)
@@ -95,6 +95,7 @@ module Renderers
9595
before do
9696
allow(pact).to receive(:content_hash).and_return(content_hash)
9797
end
98+
9899
let(:json_content) { '[1]' }
99100
let(:content_hash) { [1] }
100101

0 commit comments

Comments
 (0)