Skip to content

Commit

Permalink
fix(matrix ui): fix home link
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 1, 2020
1 parent c052bee commit 67065b7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/pact_broker/api/resources/base_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def base_url
PactBroker.configuration.base_url || request.base_uri.to_s.chomp('/')
end

# See comments for base_url in lib/pact_broker/doc/controllers/app.rb
def ui_base_url
PactBroker.configuration.base_url || ''
end

def charsets_provided
[['utf-8', :encode]]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/api/resources/latest_pact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def to_extended_json
def to_html
PactBroker.configuration.html_pact_renderer.call(
pact, {
base_url: base_url,
base_url: ui_base_url,
badge_url: "#{resource_url}/badge.svg"
})
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pact_broker/api/resources/pact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def to_extended_json
def to_html
PactBroker.configuration.html_pact_renderer.call(
pact, {
base_url: base_url,
badge_url: badge_url_for_latest_pact(pact, base_url)
base_url: ui_base_url,
badge_url: badge_url_for_latest_pact(pact, ui_base_url)
})
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

.container
.navbar-right
%a{href: base_url}
%a{href: "#{base_url}/"}
Home
%h1.page-header
= title
Expand Down
1 change: 1 addition & 0 deletions spec/lib/pact_broker/api/resources/latest_pact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Resources
before do
allow(PactBroker::Pacts::Service).to receive(:find_latest_pact).and_return(pact)
allow(PactBroker.configuration.html_pact_renderer).to receive(:call).and_return(html)
allow_any_instance_of(LatestPact).to receive(:ui_base_url).and_return('http://example.org')
end

subject { get(path, nil, 'HTTP_ACCEPT' => accept) }
Expand Down
1 change: 1 addition & 0 deletions spec/lib/pact_broker/api/resources/pact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Resources

before do
allow_any_instance_of(Pact).to receive(:badge_url_for_latest_pact).and_return('http://badge')
allow_any_instance_of(Pact).to receive(:ui_base_url).and_return('http://example.org')
allow(PactBroker::Pacts::Service).to receive(:find_pact).and_return(pact)
allow(PactBroker.configuration.html_pact_renderer).to receive(:call).and_return(html)
end
Expand Down

0 comments on commit 67065b7

Please sign in to comment.