From 3171b387be987a50a69d32b5dfcd8b3685afd901 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 12 Mar 2019 01:07:50 +0300 Subject: [PATCH] tests fix --- .../lib/block_scout_web/views/layout_view.ex | 6 ++--- .../views/layout_view_test.exs | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex index 9a2c6ae474..eabd0ab230 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex @@ -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, "#{version}"}) - else + if release_link == "" || release_link == nil do _version_link = version + else + _version_link = html_escape({:safe, "#{version}"}) end end diff --git a/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs index 140c48eb21..dd74d910f7 100644 --- a/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs @@ -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(v1.3.4) + 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(1.3.4)} + end end end