Skip to content

Commit 67065b7

Browse files
committed
fix(matrix ui): fix home link
1 parent c052bee commit 67065b7

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

lib/pact_broker/api/resources/base_resource.rb

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def base_url
6262
PactBroker.configuration.base_url || request.base_uri.to_s.chomp('/')
6363
end
6464

65+
# See comments for base_url in lib/pact_broker/doc/controllers/app.rb
66+
def ui_base_url
67+
PactBroker.configuration.base_url || ''
68+
end
69+
6570
def charsets_provided
6671
[['utf-8', :encode]]
6772
end

lib/pact_broker/api/resources/latest_pact.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def to_extended_json
3636
def to_html
3737
PactBroker.configuration.html_pact_renderer.call(
3838
pact, {
39-
base_url: base_url,
39+
base_url: ui_base_url,
4040
badge_url: "#{resource_url}/badge.svg"
4141
})
4242
end

lib/pact_broker/api/resources/pact.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def to_extended_json
7777
def to_html
7878
PactBroker.configuration.html_pact_renderer.call(
7979
pact, {
80-
base_url: base_url,
81-
badge_url: badge_url_for_latest_pact(pact, base_url)
80+
base_url: ui_base_url,
81+
badge_url: badge_url_for_latest_pact(pact, ui_base_url)
8282
})
8383
end
8484

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
.container
1212
.navbar-right
13-
%a{href: base_url}
13+
%a{href: "#{base_url}/"}
1414
Home
1515
%h1.page-header
1616
= title

spec/lib/pact_broker/api/resources/latest_pact_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Resources
2121
before do
2222
allow(PactBroker::Pacts::Service).to receive(:find_latest_pact).and_return(pact)
2323
allow(PactBroker.configuration.html_pact_renderer).to receive(:call).and_return(html)
24+
allow_any_instance_of(LatestPact).to receive(:ui_base_url).and_return('http://example.org')
2425
end
2526

2627
subject { get(path, nil, 'HTTP_ACCEPT' => accept) }

spec/lib/pact_broker/api/resources/pact_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module Resources
2424

2525
before do
2626
allow_any_instance_of(Pact).to receive(:badge_url_for_latest_pact).and_return('http://badge')
27+
allow_any_instance_of(Pact).to receive(:ui_base_url).and_return('http://example.org')
2728
allow(PactBroker::Pacts::Service).to receive(:find_pact).and_return(pact)
2829
allow(PactBroker.configuration.html_pact_renderer).to receive(:call).and_return(html)
2930
end

0 commit comments

Comments
 (0)