Test both forms of 404 for controllers

1. Not a valid hash
2. Valid hash, but does not exist
pull/162/head
Luke Imhoff 7 years ago
parent 9f874df1f5
commit f1848db0f6
  1. 6
      apps/explorer_web/priv/gettext/default.pot
  2. 6
      apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po
  3. 11
      apps/explorer_web/test/explorer_web/controllers/address_internal_transaction_controller_test.exs
  4. 10
      apps/explorer_web/test/explorer_web/controllers/address_transaction_controller_test.exs
  5. 14
      apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs
  6. 14
      apps/explorer_web/test/explorer_web/controllers/transaction_log_controller_test.exs

@ -171,7 +171,7 @@ msgstr ""
#: lib/explorer_web/templates/transaction/overview.html.eex:47
#: lib/explorer_web/templates/transaction/show.html.eex:26
#: lib/explorer_web/views/address_internal_transaction_view.ex:7
#: lib/explorer_web/views/address_transaction_view.ex:15
#: lib/explorer_web/views/address_transaction_view.ex:13
msgid "From"
msgstr ""
@ -194,7 +194,7 @@ msgstr ""
#: lib/explorer_web/templates/transaction/overview.html.eex:61
#: lib/explorer_web/templates/transaction/show.html.eex:27
#: lib/explorer_web/views/address_internal_transaction_view.ex:6
#: lib/explorer_web/views/address_transaction_view.ex:14
#: lib/explorer_web/views/address_transaction_view.ex:12
msgid "To"
msgstr ""
@ -382,7 +382,7 @@ msgstr ""
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:28
#: lib/explorer_web/templates/address_transaction/index.html.eex:29
#: lib/explorer_web/views/address_internal_transaction_view.ex:8
#: lib/explorer_web/views/address_transaction_view.ex:16
#: lib/explorer_web/views/address_transaction_view.ex:14
msgid "All"
msgstr ""

@ -183,7 +183,7 @@ msgstr "Address"
#: lib/explorer_web/templates/transaction/overview.html.eex:47
#: lib/explorer_web/templates/transaction/show.html.eex:26
#: lib/explorer_web/views/address_internal_transaction_view.ex:7
#: lib/explorer_web/views/address_transaction_view.ex:15
#: lib/explorer_web/views/address_transaction_view.ex:13
msgid "From"
msgstr "From"
@ -206,7 +206,7 @@ msgstr "Success"
#: lib/explorer_web/templates/transaction/overview.html.eex:61
#: lib/explorer_web/templates/transaction/show.html.eex:27
#: lib/explorer_web/views/address_internal_transaction_view.ex:6
#: lib/explorer_web/views/address_transaction_view.ex:14
#: lib/explorer_web/views/address_transaction_view.ex:12
msgid "To"
msgstr "To"
@ -394,7 +394,7 @@ msgstr ""
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:28
#: lib/explorer_web/templates/address_transaction/index.html.eex:29
#: lib/explorer_web/views/address_internal_transaction_view.ex:8
#: lib/explorer_web/views/address_transaction_view.ex:16
#: lib/explorer_web/views/address_transaction_view.ex:14
msgid "All"
msgstr ""

@ -4,10 +4,17 @@ defmodule ExplorerWeb.AddressInternalTransactionControllerTest do
import ExplorerWeb.Router.Helpers, only: [address_internal_transaction_path: 4]
describe "GET index/3" do
test "without address", %{conn: conn} do
test "with invalid address hash", %{conn: conn} do
conn =
conn
|> get(address_internal_transaction_path(ExplorerWeb.Endpoint, :index, :en, "0xcafe"))
|> get(address_internal_transaction_path(ExplorerWeb.Endpoint, :index, :en, "invalid_address"))
assert html_response(conn, 404)
end
test "with valid address hash without address", %{conn: conn} do
conn =
get(conn, address_internal_transaction_path(conn, :index, :en, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"))
assert html_response(conn, 404)
end

@ -4,8 +4,14 @@ defmodule ExplorerWeb.AddressTransactionControllerTest do
import ExplorerWeb.Router.Helpers, only: [address_transaction_path: 4]
describe "GET index/2" do
test "without address", %{conn: conn} do
conn = get(conn, address_transaction_path(conn, :index, :en, "unknown"))
test "with invalid address hash", %{conn: conn} do
conn = get(conn, address_transaction_path(conn, :index, :en, "invalid_address"))
assert html_response(conn, 404)
end
test "with valid address hash without address", %{conn: conn} do
conn = get(conn, address_transaction_path(conn, :index, :en, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"))
assert html_response(conn, 404)
end

@ -73,8 +73,18 @@ defmodule ExplorerWeb.TransactionControllerTest do
end
describe "GET show/3" do
test "without transaction", %{conn: conn} do
conn = get(conn, "/en/transactions/0x1")
test "with invalid transaction hash", %{conn: conn} do
conn = get(conn, transaction_path(conn, :show, :en, "invalid_transaction_hash"))
assert html_response(conn, 404)
end
test "with valid transaction hash without transaction", %{conn: conn} do
conn =
get(
conn,
transaction_path(conn, :show, :en, "0x3a3eb134e6792ce9403ea4188e5e79693de9e4c94e499db132be086400da79e6")
)
assert html_response(conn, 404)
end

@ -4,8 +4,18 @@ defmodule ExplorerWeb.TransactionLogControllerTest do
import ExplorerWeb.Router.Helpers, only: [transaction_log_path: 4]
describe "GET index/2" do
test "without transaction", %{conn: conn} do
conn = get(conn, transaction_log_path(conn, :index, :en, "unknown"))
test "with invalid transaction hash", %{conn: conn} do
conn = get(conn, transaction_log_path(conn, :index, :en, "invalid_transaction_string"))
assert html_response(conn, 404)
end
test "with valid transaction hash without transaction", %{conn: conn} do
conn =
get(
conn,
transaction_log_path(conn, :index, :en, "0x3a3eb134e6792ce9403ea4188e5e79693de9e4c94e499db132be086400da79e6")
)
assert html_response(conn, 404)
end

Loading…
Cancel
Save