Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions copi.owasp.org/lib/copi/cornucopia/vote.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Copi.Cornucopia.Vote do
@doc false
def changeset(vote, attrs) do
vote
|> cast(attrs, [])
|> validate_required([])
|> cast(attrs, [:dealt_card_id, :player_id])
|> validate_required([:dealt_card_id, :player_id])
end
end
22 changes: 22 additions & 0 deletions copi.owasp.org/test/copi/cornucopia/vote_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule Copi.Cornucopia.VoteTest do
use Copi.DataCase

alias Copi.Cornucopia.Vote

describe "votes" do
@valid_attrs %{player_id: Ecto.ULID.generate(), dealt_card_id: 1}
@invalid_attrs %{player_id: nil, dealt_card_id: nil}

test "changeset with valid attributes" do
changeset = Vote.changeset(%Vote{}, @valid_attrs)
assert changeset.valid?
end

test "changeset with invalid attributes" do
changeset = Vote.changeset(%Vote{}, @invalid_attrs)
refute changeset.valid?
assert "can't be blank" in errors_on(changeset).player_id
assert "can't be blank" in errors_on(changeset).dealt_card_id
end
end
end
Loading