pull/1539/head
Victor Baranov 6 years ago
parent 0347f5e806
commit 3171b387be
  1. 6
      apps/block_scout_web/lib/block_scout_web/views/layout_view.ex
  2. 25
      apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs

@ -79,10 +79,10 @@ defmodule BlockScoutWeb.LayoutView do
def release_link(version) do
release_link = Application.get_env(:block_scout_web, :release_link)
if String.length(release_link) > 0 do
_version_link = html_escape({:safe, "<a href=\"#{release_link}\" target=\"_blank\">#{version}</a>"})
else
if release_link == "" || release_link == nil do
_version_link = version
else
_version_link = html_escape({:safe, "<a href=\"#{release_link}\" target=\"_blank\">#{version}</a>"})
end
end

@ -62,22 +62,25 @@ defmodule BlockScoutWeb.LayoutViewTest do
end
describe "release_link/1" do
test "use the enviroment release link when it's configured" do
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, version: "1.3.4")
Application.put_env(:block_scout_web, BlockScoutWeb.Chain,
release_link: "https://github.com/poanetwork/blockscout/releases/tag/v1.3.4-beta"
)
test "use the version when there is no release_link env configured for it" do
Application.put_env(:block_scout_web, :release_link, nil)
assert LayoutView.release_link("1.3.4") ==
~s(<a href="https://github.com/poanetwork/blockscout/releases/tag/v1.3.4-beta" target="_blank">v1.3.4</a>)
assert LayoutView.release_link("1.3.4") == "1.3.4"
end
test "use the version when there is no release_link env configured for it" do
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, version: "1.3.4")
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, release_link: "")
test "use the version when empty release_link env configured for it" do
Application.put_env(:block_scout_web, :release_link, "")
assert LayoutView.release_link("1.3.4") == "1.3.4"
end
test "use the enviroment release link when it's configured" do
Application.put_env(:block_scout_web, :release_link,
"https://github.com/poanetwork/blockscout/releases/tag/v1.3.4-beta"
)
assert LayoutView.release_link("1.3.4") ==
{:safe, ~s(<a href="https://github.com/poanetwork/blockscout/releases/tag/v1.3.4-beta" target="_blank">1.3.4</a>)}
end
end
end

Loading…
Cancel
Save