Changed the bidding round status field from "running" to "stopped".
This commit is contained in:
@ -6,7 +6,7 @@ defmodule BeetRoundServer.BiddingRounds.BiddingRound do
|
|||||||
@foreign_key_type :binary_id
|
@foreign_key_type :binary_id
|
||||||
schema "bidding_rounds" do
|
schema "bidding_rounds" do
|
||||||
field :round_number, :integer
|
field :round_number, :integer
|
||||||
field :running, :boolean, default: false
|
field :stopped, :boolean, default: false
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime)
|
||||||
end
|
end
|
||||||
@ -14,7 +14,7 @@ defmodule BeetRoundServer.BiddingRounds.BiddingRound do
|
|||||||
@doc false
|
@doc false
|
||||||
def changeset(bidding_round, attrs) do
|
def changeset(bidding_round, attrs) do
|
||||||
bidding_round
|
bidding_round
|
||||||
|> cast(attrs, [:round_number, :running])
|
|> cast(attrs, [:round_number, :stopped])
|
||||||
|> validate_required([:round_number, :running])
|
|> validate_required([:round_number, :stopped])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,7 +19,7 @@ defmodule BeetRoundServerWeb.BiddingRoundJSON do
|
|||||||
%{
|
%{
|
||||||
id: bidding_round.id,
|
id: bidding_round.id,
|
||||||
round_number: bidding_round.round_number,
|
round_number: bidding_round.round_number,
|
||||||
running: bidding_round.running
|
stopped: bidding_round.stopped
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
defmodule BeetRoundServer.Repo.Migrations.BiddingRoundStatusStoppedInsteadOfRunning do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:bidding_rounds) do
|
||||||
|
add :stopped, :boolean, default: false, null: false
|
||||||
|
remove :running
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -8,7 +8,7 @@ defmodule BeetRoundServer.BiddingRoundsTest do
|
|||||||
|
|
||||||
import BeetRoundServer.BiddingRoundsFixtures
|
import BeetRoundServer.BiddingRoundsFixtures
|
||||||
|
|
||||||
@invalid_attrs %{running: nil, round_number: nil}
|
@invalid_attrs %{stopped: nil, round_number: nil}
|
||||||
|
|
||||||
test "list_bidding_rounds/0 returns all bidding_rounds" do
|
test "list_bidding_rounds/0 returns all bidding_rounds" do
|
||||||
bidding_round = bidding_round_fixture()
|
bidding_round = bidding_round_fixture()
|
||||||
@ -21,10 +21,12 @@ defmodule BeetRoundServer.BiddingRoundsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "create_bidding_round/1 with valid data creates a bidding_round" do
|
test "create_bidding_round/1 with valid data creates a bidding_round" do
|
||||||
valid_attrs = %{running: true, round_number: 42}
|
valid_attrs = %{stopped: true, round_number: 42}
|
||||||
|
|
||||||
assert {:ok, %BiddingRound{} = bidding_round} = BiddingRounds.create_bidding_round(valid_attrs)
|
assert {:ok, %BiddingRound{} = bidding_round} =
|
||||||
assert bidding_round.running == true
|
BiddingRounds.create_bidding_round(valid_attrs)
|
||||||
|
|
||||||
|
assert bidding_round.stopped == true
|
||||||
assert bidding_round.round_number == 42
|
assert bidding_round.round_number == 42
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,23 +36,31 @@ defmodule BeetRoundServer.BiddingRoundsTest do
|
|||||||
|
|
||||||
test "update_bidding_round/2 with valid data updates the bidding_round" do
|
test "update_bidding_round/2 with valid data updates the bidding_round" do
|
||||||
bidding_round = bidding_round_fixture()
|
bidding_round = bidding_round_fixture()
|
||||||
update_attrs = %{running: false, round_number: 43}
|
update_attrs = %{stopped: false, round_number: 43}
|
||||||
|
|
||||||
assert {:ok, %BiddingRound{} = bidding_round} = BiddingRounds.update_bidding_round(bidding_round, update_attrs)
|
assert {:ok, %BiddingRound{} = bidding_round} =
|
||||||
assert bidding_round.running == false
|
BiddingRounds.update_bidding_round(bidding_round, update_attrs)
|
||||||
|
|
||||||
|
assert bidding_round.stopped == false
|
||||||
assert bidding_round.round_number == 43
|
assert bidding_round.round_number == 43
|
||||||
end
|
end
|
||||||
|
|
||||||
test "update_bidding_round/2 with invalid data returns error changeset" do
|
test "update_bidding_round/2 with invalid data returns error changeset" do
|
||||||
bidding_round = bidding_round_fixture()
|
bidding_round = bidding_round_fixture()
|
||||||
assert {:error, %Ecto.Changeset{}} = BiddingRounds.update_bidding_round(bidding_round, @invalid_attrs)
|
|
||||||
|
assert {:error, %Ecto.Changeset{}} =
|
||||||
|
BiddingRounds.update_bidding_round(bidding_round, @invalid_attrs)
|
||||||
|
|
||||||
assert bidding_round == BiddingRounds.get_bidding_round!(bidding_round.id)
|
assert bidding_round == BiddingRounds.get_bidding_round!(bidding_round.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delete_bidding_round/1 deletes the bidding_round" do
|
test "delete_bidding_round/1 deletes the bidding_round" do
|
||||||
bidding_round = bidding_round_fixture()
|
bidding_round = bidding_round_fixture()
|
||||||
assert {:ok, %BiddingRound{}} = BiddingRounds.delete_bidding_round(bidding_round)
|
assert {:ok, %BiddingRound{}} = BiddingRounds.delete_bidding_round(bidding_round)
|
||||||
assert_raise Ecto.NoResultsError, fn -> BiddingRounds.get_bidding_round!(bidding_round.id) end
|
|
||||||
|
assert_raise Ecto.NoResultsError, fn ->
|
||||||
|
BiddingRounds.get_bidding_round!(bidding_round.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "change_bidding_round/1 returns a bidding_round changeset" do
|
test "change_bidding_round/1 returns a bidding_round changeset" do
|
||||||
|
|||||||
@ -5,14 +5,14 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
|
|||||||
alias BeetRoundServer.BiddingRounds.BiddingRound
|
alias BeetRoundServer.BiddingRounds.BiddingRound
|
||||||
|
|
||||||
@create_attrs %{
|
@create_attrs %{
|
||||||
running: true,
|
stopped: true,
|
||||||
round_number: 42
|
round_number: 42
|
||||||
}
|
}
|
||||||
@update_attrs %{
|
@update_attrs %{
|
||||||
running: false,
|
stopped: false,
|
||||||
round_number: 43
|
round_number: 43
|
||||||
}
|
}
|
||||||
@invalid_attrs %{running: nil, round_number: nil}
|
@invalid_attrs %{stopped: nil, round_number: nil}
|
||||||
|
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
{:ok, conn: put_req_header(conn, "accept", "application/json")}
|
{:ok, conn: put_req_header(conn, "accept", "application/json")}
|
||||||
@ -35,7 +35,7 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
|
|||||||
assert %{
|
assert %{
|
||||||
"id" => ^id,
|
"id" => ^id,
|
||||||
"round_number" => 42,
|
"round_number" => 42,
|
||||||
"running" => true
|
"stopped" => true
|
||||||
} = json_response(conn, 200)["data"]
|
} = json_response(conn, 200)["data"]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,7 +48,10 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
|
|||||||
describe "update bidding_round" do
|
describe "update bidding_round" do
|
||||||
setup [:create_bidding_round]
|
setup [:create_bidding_round]
|
||||||
|
|
||||||
test "renders bidding_round when data is valid", %{conn: conn, bidding_round: %BiddingRound{id: id} = bidding_round} do
|
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)
|
conn = put(conn, ~p"/api/bidding_rounds/#{bidding_round}", bidding_round: @update_attrs)
|
||||||
assert %{"id" => ^id} = json_response(conn, 200)["data"]
|
assert %{"id" => ^id} = json_response(conn, 200)["data"]
|
||||||
|
|
||||||
@ -57,7 +60,7 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
|
|||||||
assert %{
|
assert %{
|
||||||
"id" => ^id,
|
"id" => ^id,
|
||||||
"round_number" => 43,
|
"round_number" => 43,
|
||||||
"running" => false
|
"stopped" => false
|
||||||
} = json_response(conn, 200)["data"]
|
} = json_response(conn, 200)["data"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ defmodule BeetRoundServer.BiddingRoundsFixtures do
|
|||||||
attrs
|
attrs
|
||||||
|> Enum.into(%{
|
|> Enum.into(%{
|
||||||
round_number: 42,
|
round_number: 42,
|
||||||
running: true
|
stopped: false
|
||||||
})
|
})
|
||||||
|> BeetRoundServer.BiddingRounds.create_bidding_round()
|
|> BeetRoundServer.BiddingRounds.create_bidding_round()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user