Fix `languages` tests.
parent
e43009f166
commit
54c7d14669
|
@ -5,13 +5,14 @@ defmodule BoardWise.Languages.Language do
|
||||||
schema "languages" do
|
schema "languages" do
|
||||||
field :code, :string
|
field :code, :string
|
||||||
field :name, :string
|
field :name, :string
|
||||||
|
field :pos, :integer
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def changeset(language, attrs) do
|
def changeset(language, attrs) do
|
||||||
language
|
language
|
||||||
|> cast(attrs, [:code, :name])
|
|> cast(attrs, [:code, :name, :pos])
|
||||||
|> validate_required([:code, :name])
|
|> validate_required([:code, :name, :pos])
|
||||||
|> unique_constraint(:code_unique, name: :code_unique)
|
|> unique_constraint(:code_unique, name: :code_unique)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ defmodule BoardWise.LanguagesTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "create_language/1 with valid data creates a language" do
|
test "create_language/1 with valid data creates a language" do
|
||||||
valid_attrs = %{code: "some code", name: "some name"}
|
valid_attrs = %{code: "some code", name: "some name", pos: 1000}
|
||||||
|
|
||||||
assert {:ok, %Language{} = language} = Languages.create_language(valid_attrs)
|
assert {:ok, %Language{} = language} = Languages.create_language(valid_attrs)
|
||||||
assert language.code == "some code"
|
assert language.code == "some code"
|
||||||
|
|
|
@ -12,7 +12,8 @@ defmodule BoardWise.LanguagesFixtures do
|
||||||
attrs
|
attrs
|
||||||
|> Enum.into(%{
|
|> Enum.into(%{
|
||||||
code: "some code",
|
code: "some code",
|
||||||
name: "some name"
|
name: "some name",
|
||||||
|
pos: 0
|
||||||
})
|
})
|
||||||
|> BoardWise.Languages.create_language()
|
|> BoardWise.Languages.create_language()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue