Skip to content

Commit

Permalink
feat(pact ui): update matrix URL to specify the latest provider version
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 25, 2020
1 parent 99b36d5 commit 23b02c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ def matrix_for_pacticipant_version_url(version, base_url = '')
"#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}"
end

def matrix_for_pact_url(pact, base_url = '')
query = {
q: [
{ pacticipant: pact.consumer_name, version: pact.consumer_version_number },
{ pacticipant: pact.provider_name, latest: true }
],
latestby: 'cvpv'
}
"#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}"
end

def matrix_url_from_params params, base_url = ''
matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/api/renderers/html_pact_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def pact_url
end

def matrix_url
PactBroker::Api::PactBrokerUrls.matrix_for_pacticipant_version_url(@pact.consumer_version, base_url)
PactBroker::Api::PactBrokerUrls.matrix_for_pact_url(@pact, base_url)
end

def latest_pact_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Renderers
ENV['TZ'] = "Australia/Melbourne"
PactBroker.configuration.enable_public_badge_access = true
allow(PactBroker::Api::PactBrokerUrls).to receive(:pact_url).with('http://base', pact).and_return(pact_url)
allow(PactBroker::Api::PactBrokerUrls).to receive(:matrix_for_pacticipant_version_url).with(consumer_version, 'http://base').and_return(matrix_url)
allow(PactBroker::Api::PactBrokerUrls).to receive(:matrix_for_pact_url).with(pact, 'http://base').and_return(matrix_url)
allow_any_instance_of(HtmlPactRenderer).to receive(:logger).and_return(logger)

Timecop.freeze(created_at + 3)
Expand Down Expand Up @@ -95,6 +95,7 @@ module Renderers
before do
allow(pact).to receive(:content_hash).and_return(content_hash)
end

let(:json_content) { '[1]' }
let(:content_hash) { [1] }

Expand Down

0 comments on commit 23b02c8

Please sign in to comment.