Changed the bidding round status field from "running" to "stopped".

This commit is contained in:
2026-02-12 11:00:14 +01:00
parent 647da6c9d7
commit e01042130e
6 changed files with 43 additions and 20 deletions

View File

@ -6,7 +6,7 @@ defmodule BeetRoundServer.BiddingRounds.BiddingRound do
@foreign_key_type :binary_id
schema "bidding_rounds" do
field :round_number, :integer
field :running, :boolean, default: false
field :stopped, :boolean, default: false
timestamps(type: :utc_datetime)
end
@ -14,7 +14,7 @@ defmodule BeetRoundServer.BiddingRounds.BiddingRound do
@doc false
def changeset(bidding_round, attrs) do
bidding_round
|> cast(attrs, [:round_number, :running])
|> validate_required([:round_number, :running])
|> cast(attrs, [:round_number, :stopped])
|> validate_required([:round_number, :stopped])
end
end

View File

@ -19,7 +19,7 @@ defmodule BeetRoundServerWeb.BiddingRoundJSON do
%{
id: bidding_round.id,
round_number: bidding_round.round_number,
running: bidding_round.running
stopped: bidding_round.stopped
}
end
end

View File

@ -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

View File

@ -8,7 +8,7 @@ defmodule BeetRoundServer.BiddingRoundsTest do
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
bidding_round = bidding_round_fixture()
@ -21,10 +21,12 @@ defmodule BeetRoundServer.BiddingRoundsTest do
end
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 bidding_round.running == true
assert {:ok, %BiddingRound{} = bidding_round} =
BiddingRounds.create_bidding_round(valid_attrs)
assert bidding_round.stopped == true
assert bidding_round.round_number == 42
end
@ -34,23 +36,31 @@ defmodule BeetRoundServer.BiddingRoundsTest do
test "update_bidding_round/2 with valid data updates the bidding_round" do
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 bidding_round.running == false
assert {:ok, %BiddingRound{} = bidding_round} =
BiddingRounds.update_bidding_round(bidding_round, update_attrs)
assert bidding_round.stopped == false
assert bidding_round.round_number == 43
end
test "update_bidding_round/2 with invalid data returns error changeset" do
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)
end
test "delete_bidding_round/1 deletes the bidding_round" do
bidding_round = bidding_round_fixture()
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
test "change_bidding_round/1 returns a bidding_round changeset" do

View File

@ -5,14 +5,14 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
alias BeetRoundServer.BiddingRounds.BiddingRound
@create_attrs %{
running: true,
stopped: true,
round_number: 42
}
@update_attrs %{
running: false,
stopped: false,
round_number: 43
}
@invalid_attrs %{running: nil, round_number: nil}
@invalid_attrs %{stopped: nil, round_number: nil}
setup %{conn: conn} do
{:ok, conn: put_req_header(conn, "accept", "application/json")}
@ -35,7 +35,7 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
assert %{
"id" => ^id,
"round_number" => 42,
"running" => true
"stopped" => true
} = json_response(conn, 200)["data"]
end
@ -48,7 +48,10 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
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
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"]
@ -57,7 +60,7 @@ defmodule BeetRoundServerWeb.BiddingRoundControllerTest do
assert %{
"id" => ^id,
"round_number" => 43,
"running" => false
"stopped" => false
} = json_response(conn, 200)["data"]
end

View File

@ -12,7 +12,7 @@ defmodule BeetRoundServer.BiddingRoundsFixtures do
attrs
|> Enum.into(%{
round_number: 42,
running: true
stopped: false
})
|> BeetRoundServer.BiddingRounds.create_bidding_round()