Mark to_address_hash as optional association on block->transactions page
pull/256/head
John Stamates 7 years ago committed by GitHub
commit 249390a45e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/explorer_web/lib/explorer_web/controllers/block_transaction_controller.ex
  2. 20
      apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs

@ -15,7 +15,7 @@ defmodule ExplorerWeb.BlockTransactionController do
necessity_by_association: %{ necessity_by_association: %{
block: :required, block: :required,
from_address: :required, from_address: :required,
to_address: :required to_address: :optional
}, },
pagination: params pagination: params
) )

@ -19,14 +19,13 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do
test "returns transactions for the block", %{conn: conn} do test "returns transactions for the block", %{conn: conn} do
block = insert(:block) block = insert(:block)
:transaction :transaction |> insert() |> with_block(block)
|> insert() :transaction |> insert(to_address_hash: nil) |> with_block(block)
|> with_block(block)
conn = get(conn, block_transaction_path(ExplorerWeb.Endpoint, :index, :en, block.number)) conn = get(conn, block_transaction_path(ExplorerWeb.Endpoint, :index, :en, block.number))
assert html_response(conn, 200) assert html_response(conn, 200)
assert 1 == Enum.count(conn.assigns.page) assert 2 == Enum.count(conn.assigns.page)
end end
test "does not return unrelated transactions", %{conn: conn} do test "does not return unrelated transactions", %{conn: conn} do
@ -48,18 +47,5 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do
assert html_response(conn, 200) assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.page) assert Enum.empty?(conn.assigns.page)
end end
test "does not return related transactions without a to address", %{conn: conn} do
block = insert(:block)
:transaction
|> insert(to_address_hash: nil)
|> with_block(block)
conn = get(conn, block_transaction_path(ExplorerWeb.Endpoint, :index, :en, block))
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.page)
end
end end
end end

Loading…
Cancel
Save