From 3ef8293dedf57109ab7d0ddfee0c380e4fb8dce6 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 25 Mar 2019 10:04:48 +0300 Subject: [PATCH] add response bodies --- .../api/v1/decompiled_smart_contract_controller.ex | 6 +++--- .../api/v1/decompiled_smart_contract_controller_test.exs | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex index b0ebc5b40e..ab71f6c910 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller.ex @@ -9,13 +9,13 @@ defmodule BlockScoutWeb.API.V1.DecompiledSmartContractController do with :ok <- validate_address_hash(params["address_hash"]) do case Chain.create_decompiled_smart_contract(params) do {:ok, _decompiled_source_code} -> - send_resp(conn, :created, "") + send_resp(conn, :created, "ok") {:error, _changeset} -> - send_resp(conn, :unprocessable_entity, "") + send_resp(conn, :unprocessable_entity, "error") end else - :error -> send_resp(conn, :unprocessable_entity, "") + :error -> send_resp(conn, :unprocessable_entity, "error") end else send_resp(conn, :forbidden, "") diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs index 3aa6eb5387..72a54010bd 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs @@ -22,6 +22,7 @@ defmodule BlockScoutWeb.API.V1.DecompiledControllerTest do request = post(conn, api_v1_decompiled_smart_contract_path(conn, :create)) assert request.status == 422 + assert request.resp_body == "error" end test "returns unprocessable_entity when address_hash is invalid", %{conn: conn} do @@ -37,6 +38,7 @@ defmodule BlockScoutWeb.API.V1.DecompiledControllerTest do request = post(conn, api_v1_decompiled_smart_contract_path(conn, :create), params) assert request.status == 422 + assert request.resp_body == "error" end test "creates decompiled smart contract", %{conn: conn} do @@ -53,6 +55,7 @@ defmodule BlockScoutWeb.API.V1.DecompiledControllerTest do request = post(conn, api_v1_decompiled_smart_contract_path(conn, :create), params) assert request.status == 201 + assert request.resp_body == "ok" decompiled_smart_contract = Repo.one!(from(d in DecompiledSmartContract, where: d.address_hash == ^address_hash)) assert to_string(decompiled_smart_contract.address_hash) == address_hash