Merge pull request #7954 from blockscout/vb-enhance-email-tests

Enhance Account Explorer.Account.Notifier.Email module tests
pull/7955/head
Victor Baranov 1 year ago committed by GitHub
commit 1c02d7fb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 26
      apps/explorer/lib/explorer/account/notifier/email.ex
  3. 19
      apps/explorer/test/explorer/account/notifier/email_test.exs
  4. 2
      apps/explorer/test/explorer/account/notifier/notify_test.exs
  5. 2
      apps/explorer/test/explorer/account/notifier/summary_test.exs

@ -28,6 +28,7 @@
### Chore
- [#7954](https://github.com/blockscout/blockscout/pull/7954) - Enhance Account Explorer.Account.Notifier.Email module tests
- [#7950](https://github.com/blockscout/blockscout/pull/7950) - Add GA CI for Eth Goerli chain
- [#7934](https://github.com/blockscout/blockscout/pull/7934), [#7936](https://github.com/blockscout/blockscout/pull/7936) - Explicitly set consensus == true in queries (convenient for search), remove logger requirements, where it is not used anymore
- [#7901](https://github.com/blockscout/blockscout/pull/7901) - Fix Docker image build

@ -122,23 +122,41 @@ defmodule Explorer.Account.Notifier.Email do
end
defp block_url(notification) do
URI.to_string(uri()) <> "block/" <> Integer.to_string(notification.block_number)
Helpers.block_url(uri(), :show, Integer.to_string(notification.block_number))
end
defp transaction_url(notification) do
Helpers.transaction_url(uri(), :show, notification.transaction_hash)
end
defp url_params do
Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url]
end
defp uri do
%URI{scheme: "https", host: host(), path: path()}
%URI{scheme: scheme(), host: host(), port: port(), path: path()}
end
defp scheme do
Keyword.get(url_params(), :scheme, "http")
end
defp host do
Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:host]
url_params()[:host]
end
defp port do
url_params()[:http][:port]
end
defp path do
Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:path]
raw_path = url_params()[:path]
if raw_path |> String.ends_with?("/") do
raw_path |> String.slice(0..-2)
else
raw_path
end
end
defp sender do

@ -1,4 +1,4 @@
defmodule Explorer.Account.Notify.EmailTest do
defmodule Explorer.Account.Notifier.EmailTest do
use ExUnit.Case
alias Explorer.Account.{
@ -20,8 +20,11 @@ defmodule Explorer.Account.Notify.EmailTest do
setup do
host = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:host]
path = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:path]
scheme = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url][:scheme]
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint, url: [host: "localhost", path: "/"])
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint,
url: [scheme: "https", host: "eth.blockscout.com", path: "/", port: 443]
)
Application.put_env(:explorer, Explorer.Account,
sendgrid: [
@ -33,7 +36,7 @@ defmodule Explorer.Account.Notify.EmailTest do
:ok
on_exit(fn ->
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint, url: [host: host, path: path])
Application.put_env(:block_scout_web, BlockScoutWeb.Endpoint, url: [scheme: scheme, host: host, path: path])
end)
end
@ -91,20 +94,20 @@ defmodule Explorer.Account.Notify.EmailTest do
dynamic_template_data: %{
"address_hash" => "0xe1f4dd38f00b0d8d4d2b4b5010be53f2a0b934e5",
"address_name" => "wallet",
"address_url" => "https://localhost//address/0xe1f4dd38f00b0d8d4d2b4b5010be53f2a0b934e5",
"address_url" => "https://eth.blockscout.com/address/0xe1f4dd38f00b0d8d4d2b4b5010be53f2a0b934e5",
"amount" => Decimal.new(1),
"block_number" => 24_121_177,
"block_url" => "https://localhost/block/24121177",
"block_url" => "https://eth.blockscout.com/block/24121177",
"direction" => "received at",
"from_address_hash" => "0x092d537737e767dae48c28ae509f34094496f030",
"from_url" => "https://localhost//address/0x092d537737e767dae48c28ae509f34094496f030",
"from_url" => "https://eth.blockscout.com/address/0x092d537737e767dae48c28ae509f34094496f030",
"method" => "transfer",
"name" => "wallet",
"to_address_hash" => "0xe1f4dd38f00b0d8d4d2b4b5010be53f2a0b934e5",
"to_url" => "https://localhost//address/0xe1f4dd38f00b0d8d4d2b4b5010be53f2a0b934e5",
"to_url" => "https://eth.blockscout.com/address/0xe1f4dd38f00b0d8d4d2b4b5010be53f2a0b934e5",
"transaction_hash" => "0x5d5ff210261f1b2d6e4af22ea494f428f9997d4ab614a629d4f1390004b3e80d",
"transaction_url" =>
"https://localhost//tx/0x5d5ff210261f1b2d6e4af22ea494f428f9997d4ab614a629d4f1390004b3e80d",
"https://eth.blockscout.com/tx/0x5d5ff210261f1b2d6e4af22ea494f428f9997d4ab614a629d4f1390004b3e80d",
"tx_fee" => Decimal.new(210_000),
"username" => "John Snow"
},

@ -1,4 +1,4 @@
defmodule Explorer.Account.Notify.NotifyTest do
defmodule Explorer.Account.Notifier.NotifyTest do
# use ExUnit.Case
use Explorer.DataCase

@ -1,4 +1,4 @@
defmodule Explorer.Account.Notify.SummaryTest do
defmodule Explorer.Account.Notifier.SummaryTest do
use Explorer.DataCase
import Explorer.Factory
Loading…
Cancel
Save