Skip to content

Commit

Permalink
fix(index page): correct pact URL when showing index with tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jul 25, 2018
1 parent 3008140 commit a5bda98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion lib/pact_broker/ui/view_models/index_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/ui/views/index/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions spec/lib/pact_broker/ui/view_models/index_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) { [] }
Expand All @@ -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" }
Expand Down

0 comments on commit a5bda98

Please sign in to comment.