diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index 7da399dfb..ffb1e71ed 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -50,7 +50,7 @@ def pact_url base_url, pact "#{pactigration_base_url(base_url, pact)}/version/#{pact.consumer_version_number}" end - def pact_version_url pact, base_url + def pact_version_url pact, base_url = '' "#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}" end diff --git a/lib/pact_broker/ui/view_models/index_item.rb b/lib/pact_broker/ui/view_models/index_item.rb index c24c83463..5bdb9d21e 100644 --- a/lib/pact_broker/ui/view_models/index_item.rb +++ b/lib/pact_broker/ui/view_models/index_item.rb @@ -50,10 +50,14 @@ def provider_group_url Helpers::URLHelper.group_url provider_name end - def pact_url + def latest_pact_url "#{pactigration_base_url('', @relationship)}/latest" end + def pact_url + PactBroker::Api::PactBrokerUrls.pact_url('', @relationship) + end + def pact_matrix_url Helpers::URLHelper.matrix_url consumer_name, provider_name end diff --git a/lib/pact_broker/ui/views/index/show.haml b/lib/pact_broker/ui/views/index/show.haml index b57be6425..b7f52885e 100644 --- a/lib/pact_broker/ui/views/index/show.haml +++ b/lib/pact_broker/ui/views/index/show.haml @@ -44,7 +44,7 @@ = index_item.consumer_name %td.pact %span.pact - %a{ href: index_item.pact_url, :title => "View pact" } + %a{ href: index_item.latest_pact_url, :title => "View pact" } %span.pact-matrix %a{ href: index_item.pact_matrix_url, title: "View pact matrix" } %td.provider diff --git a/spec/lib/pact_broker/ui/view_models/index_item_spec.rb b/spec/lib/pact_broker/ui/view_models/index_item_spec.rb index ec29f76cc..ab35ee771 100644 --- a/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +++ b/spec/lib/pact_broker/ui/view_models/index_item_spec.rb @@ -9,7 +9,7 @@ module ViewDomain let(:consumer) { instance_double("PactBroker::Domain::Pacticipant", name: 'Consumer Name')} let(:provider) { instance_double("PactBroker::Domain::Pacticipant", name: 'Provider Name')} - let(:latest_pact) { instance_double("PactBroker::Domain::Pact") } + let(:latest_pact) { instance_double("PactBroker::Domain::Pact", consumer_version_number: "1.2.3") } let(:latest_verification) { instance_double("PactBroker::Domain::Verification") } let(:domain_relationship) { PactBroker::Domain::IndexItem.new(consumer, provider, latest_pact, latest, latest_verification, [], [], tags, latest_verification_latest_tags)} let(:tags) { [] } @@ -22,7 +22,8 @@ module ViewDomain its(:consumer_name) { should eq 'Consumer Name'} its(:provider_name) { should eq 'Provider Name'} - its(:pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/latest" } + its(:latest_pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/latest" } + its(:pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/version/1.2.3" } its(:pact_matrix_url) { should eq "/matrix/provider/Provider%20Name/consumer/Consumer%20Name" } its(:consumer_group_url) { should eq "/groups/Consumer%20Name" } its(:provider_group_url) { should eq "/groups/Provider%20Name" }