Skip to content

Commit a5bda98

Browse files
committed
fix(index page): correct pact URL when showing index with tags
1 parent 3008140 commit a5bda98

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

lib/pact_broker/api/pact_broker_urls.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def pact_url base_url, pact
5050
"#{pactigration_base_url(base_url, pact)}/version/#{pact.consumer_version_number}"
5151
end
5252

53-
def pact_version_url pact, base_url
53+
def pact_version_url pact, base_url = ''
5454
"#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}"
5555
end
5656

lib/pact_broker/ui/view_models/index_item.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ def provider_group_url
5050
Helpers::URLHelper.group_url provider_name
5151
end
5252

53-
def pact_url
53+
def latest_pact_url
5454
"#{pactigration_base_url('', @relationship)}/latest"
5555
end
5656

57+
def pact_url
58+
PactBroker::Api::PactBrokerUrls.pact_url('', @relationship)
59+
end
60+
5761
def pact_matrix_url
5862
Helpers::URLHelper.matrix_url consumer_name, provider_name
5963
end

lib/pact_broker/ui/views/index/show.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
= index_item.consumer_name
4545
%td.pact
4646
%span.pact
47-
%a{ href: index_item.pact_url, :title => "View pact" }
47+
%a{ href: index_item.latest_pact_url, :title => "View pact" }
4848
%span.pact-matrix
4949
%a{ href: index_item.pact_matrix_url, title: "View pact matrix" }
5050
%td.provider

spec/lib/pact_broker/ui/view_models/index_item_spec.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module ViewDomain
99

1010
let(:consumer) { instance_double("PactBroker::Domain::Pacticipant", name: 'Consumer Name')}
1111
let(:provider) { instance_double("PactBroker::Domain::Pacticipant", name: 'Provider Name')}
12-
let(:latest_pact) { instance_double("PactBroker::Domain::Pact") }
12+
let(:latest_pact) { instance_double("PactBroker::Domain::Pact", consumer_version_number: "1.2.3") }
1313
let(:latest_verification) { instance_double("PactBroker::Domain::Verification") }
1414
let(:domain_relationship) { PactBroker::Domain::IndexItem.new(consumer, provider, latest_pact, latest, latest_verification, [], [], tags, latest_verification_latest_tags)}
1515
let(:tags) { [] }
@@ -22,7 +22,8 @@ module ViewDomain
2222

2323
its(:consumer_name) { should eq 'Consumer Name'}
2424
its(:provider_name) { should eq 'Provider Name'}
25-
its(:pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/latest" }
25+
its(:latest_pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/latest" }
26+
its(:pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/version/1.2.3" }
2627
its(:pact_matrix_url) { should eq "/matrix/provider/Provider%20Name/consumer/Consumer%20Name" }
2728
its(:consumer_group_url) { should eq "/groups/Consumer%20Name" }
2829
its(:provider_group_url) { should eq "/groups/Provider%20Name" }

0 commit comments

Comments
 (0)