parent
ea89902120
commit
882f09abcd
@ -1,15 +0,0 @@ |
|||||||
defmodule ExplorerWeb.AddressQRCodeController do |
|
||||||
use ExplorerWeb, :controller |
|
||||||
|
|
||||||
alias Explorer.Chain.Hash.Truncated |
|
||||||
|
|
||||||
def index(conn, %{"address_id" => id}) do |
|
||||||
case Truncated.cast(id) do |
|
||||||
{:ok, _} -> |
|
||||||
send_download(conn, {:binary, QRCode.to_png(id)}, "content-type": "image/png", filename: "#{id}.png") |
|
||||||
|
|
||||||
_ -> |
|
||||||
send_resp(conn, :not_found, "") |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
@ -1,15 +0,0 @@ |
|||||||
defmodule ExplorerWeb.TransactionQRCodeController do |
|
||||||
use ExplorerWeb, :controller |
|
||||||
|
|
||||||
alias Explorer.Chain.Hash.Full |
|
||||||
|
|
||||||
def index(conn, %{"transaction_id" => id}) do |
|
||||||
case Full.cast(id) do |
|
||||||
{:ok, _} -> |
|
||||||
send_download(conn, {:binary, QRCode.to_png(id)}, "content-type": "image/png", filename: "#{id}.png") |
|
||||||
|
|
||||||
_ -> |
|
||||||
send_resp(conn, :not_found, "") |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
@ -1,19 +0,0 @@ |
|||||||
defmodule ExplorerWeb.AddressQRCodeControllerTest do |
|
||||||
use ExplorerWeb.ConnCase |
|
||||||
|
|
||||||
import ExplorerWeb.Router.Helpers, only: [address_qr_code_path: 4] |
|
||||||
|
|
||||||
describe "GET index/3" do |
|
||||||
test "with valid address hash returns a QR code", %{conn: conn} do |
|
||||||
conn = get(conn, address_qr_code_path(conn, :index, :en, address_hash())) |
|
||||||
|
|
||||||
assert response(conn, 200) |
|
||||||
end |
|
||||||
|
|
||||||
test "with invalid address hash returns 404", %{conn: conn} do |
|
||||||
conn = get(conn, address_qr_code_path(conn, :index, :en, "0xhaha")) |
|
||||||
|
|
||||||
assert response(conn, 404) |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
@ -1,19 +0,0 @@ |
|||||||
defmodule ExplorerWeb.TransactionQRCodeControllerTest do |
|
||||||
use ExplorerWeb.ConnCase |
|
||||||
|
|
||||||
import ExplorerWeb.Router.Helpers, only: [transaction_qr_code_path: 4] |
|
||||||
|
|
||||||
describe "GET index/3" do |
|
||||||
test "with valid `Hash.Full` returns a QR code", %{conn: conn} do |
|
||||||
conn = get(conn, transaction_qr_code_path(conn, :index, :en, transaction_hash())) |
|
||||||
|
|
||||||
assert response(conn, 200) |
|
||||||
end |
|
||||||
|
|
||||||
test "with invalid address hash returns 404", %{conn: conn} do |
|
||||||
conn = get(conn, transaction_qr_code_path(conn, :index, :en, "0xhaha")) |
|
||||||
|
|
||||||
assert response(conn, 404) |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
Loading…
Reference in new issue