After "mix phx.gen.json BiddingRounds BiddingRound bidding_rounds round_number:integer running:boolean --no-scope".
This commit is contained in:
@ -0,0 +1,88 @@
|
||||
defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
|
||||
use BeetRoundServerWeb.ConnCase
|
||||
|
||||
import BeetRoundServer.BiddingRoundsFixtures
|
||||
alias BeetRoundServer.BiddingRounds.BiddingRound
|
||||
|
||||
@create_attrs %{
|
||||
running: true,
|
||||
round_number: 42
|
||||
}
|
||||
@update_attrs %{
|
||||
running: false,
|
||||
round_number: 43
|
||||
}
|
||||
@invalid_attrs %{running: nil, round_number: nil}
|
||||
|
||||
setup %{conn: conn} do
|
||||
{:ok, conn: put_req_header(conn, "accept", "application/json")}
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
test "lists all bidding_rounds", %{conn: conn} do
|
||||
conn = get(conn, ~p"/api/bidding_rounds")
|
||||
assert json_response(conn, 200)["data"] == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "create bidding_round" do
|
||||
test "renders bidding_round when data is valid", %{conn: conn} do
|
||||
conn = post(conn, ~p"/api/bidding_rounds", bidding_round: @create_attrs)
|
||||
assert %{"id" => id} = json_response(conn, 201)["data"]
|
||||
|
||||
conn = get(conn, ~p"/api/bidding_rounds/#{id}")
|
||||
|
||||
assert %{
|
||||
"id" => ^id,
|
||||
"round_number" => 42,
|
||||
"running" => true
|
||||
} = json_response(conn, 200)["data"]
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, ~p"/api/bidding_rounds", bidding_round: @invalid_attrs)
|
||||
assert json_response(conn, 422)["errors"] != %{}
|
||||
end
|
||||
end
|
||||
|
||||
describe "update bidding_round" do
|
||||
setup [:create_bidding_round]
|
||||
|
||||
test "renders bidding_round when data is valid", %{conn: conn, bidding_round: %BiddingRound{id: id} = bidding_round} do
|
||||
conn = put(conn, ~p"/api/bidding_rounds/#{bidding_round}", bidding_round: @update_attrs)
|
||||
assert %{"id" => ^id} = json_response(conn, 200)["data"]
|
||||
|
||||
conn = get(conn, ~p"/api/bidding_rounds/#{id}")
|
||||
|
||||
assert %{
|
||||
"id" => ^id,
|
||||
"round_number" => 43,
|
||||
"running" => false
|
||||
} = json_response(conn, 200)["data"]
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, bidding_round: bidding_round} do
|
||||
conn = put(conn, ~p"/api/bidding_rounds/#{bidding_round}", bidding_round: @invalid_attrs)
|
||||
assert json_response(conn, 422)["errors"] != %{}
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete bidding_round" do
|
||||
setup [:create_bidding_round]
|
||||
|
||||
test "deletes chosen bidding_round", %{conn: conn, bidding_round: bidding_round} do
|
||||
conn = delete(conn, ~p"/api/bidding_rounds/#{bidding_round}")
|
||||
assert response(conn, 204)
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, ~p"/api/bidding_rounds/#{bidding_round}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_bidding_round(_) do
|
||||
bidding_round = bidding_round_fixture()
|
||||
|
||||
%{bidding_round: bidding_round}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user