mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Fix tests
This commit is contained in:
parent
01471967c8
commit
69f05a1c5d
@ -30,6 +30,7 @@ config :chess, Chess.Auth.Guardian,
|
|||||||
secret_key: "vd2vXkrYTTFKSKmNMoS2/Hk4Fxn8BkyzsVArRkxJazdQ3mr6bI4YgAC6f8ODiWlM"
|
secret_key: "vd2vXkrYTTFKSKmNMoS2/Hk4Fxn8BkyzsVArRkxJazdQ3mr6bI4YgAC6f8ODiWlM"
|
||||||
|
|
||||||
config :formulator,
|
config :formulator,
|
||||||
|
validate: false,
|
||||||
translate_error_module: ChessWeb.ErrorHelpers
|
translate_error_module: ChessWeb.ErrorHelpers
|
||||||
|
|
||||||
# Configure esbuild (the version is required)
|
# Configure esbuild (the version is required)
|
||||||
|
|||||||
@ -76,6 +76,7 @@ defmodule Chess.Store.User do
|
|||||||
if password do
|
if password do
|
||||||
changeset
|
changeset
|
||||||
|> change(Argon2.add_hash(password))
|
|> change(Argon2.add_hash(password))
|
||||||
|
|> change(password: nil)
|
||||||
else
|
else
|
||||||
changeset
|
changeset
|
||||||
end
|
end
|
||||||
|
|||||||
@ -76,15 +76,13 @@ defmodule Chess.AuthTest do
|
|||||||
|
|
||||||
test "authenticate_user/1 returns false on incorrect password " do
|
test "authenticate_user/1 returns false on incorrect password " do
|
||||||
user_fixture(email: "link@hyrule.com", password: "eyeofsheikah")
|
user_fixture(email: "link@hyrule.com", password: "eyeofsheikah")
|
||||||
assert {:error, message} =
|
assert {:error, message} = Auth.authenticate_user("link@hyrule.com", "shadowtemple")
|
||||||
Auth.authenticate_user("link@hyrule.com", "shadowtemple")
|
|
||||||
assert message == "invalid password"
|
assert message == "invalid password"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "authenticate_user/1 returns true on correct password " do
|
test "authenticate_user/1 returns true on correct password " do
|
||||||
user = user_fixture(email: "link@hyrule.com", password: "eyeofsheikah")
|
user = user_fixture(email: "link@hyrule.com", password: "eyeofsheikah")
|
||||||
assert {:ok, ^user} =
|
assert {:ok, ^user} = Auth.authenticate_user("link@hyrule.com", "eyeofsheikah")
|
||||||
Auth.authenticate_user("link@hyrule.com", "eyeofsheikah")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,8 @@ defmodule Chess.Features.ProfileTest do
|
|||||||
import Chess.AuthenticationHelpers
|
import Chess.AuthenticationHelpers
|
||||||
|
|
||||||
test "user can update their details", %{session: session} do
|
test "user can update their details", %{session: session} do
|
||||||
user = insert(:user, %{
|
user =
|
||||||
|
insert(:user, %{
|
||||||
name: "Link",
|
name: "Link",
|
||||||
email: "link@hyrule.com",
|
email: "link@hyrule.com",
|
||||||
password: "ilovezelda"
|
password: "ilovezelda"
|
||||||
@ -25,7 +26,8 @@ defmodule Chess.Features.ProfileTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "name cannot be blank", %{session: session} do
|
test "name cannot be blank", %{session: session} do
|
||||||
user = insert(:user, %{
|
user =
|
||||||
|
insert(:user, %{
|
||||||
name: "Link",
|
name: "Link",
|
||||||
email: "link@hyrule.com",
|
email: "link@hyrule.com",
|
||||||
password: "ilovezelda"
|
password: "ilovezelda"
|
||||||
@ -40,13 +42,12 @@ defmodule Chess.Features.ProfileTest do
|
|||||||
|> click(button("Update Profile"))
|
|> click(button("Update Profile"))
|
||||||
|
|
||||||
session
|
session
|
||||||
|> assert_has(
|
|> assert_has(css("[data-role='name-error']", text: "can't be blank"))
|
||||||
css("[data-role='name-error']", text: "can't be blank")
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "email cannot be blank", %{session: session} do
|
test "email cannot be blank", %{session: session} do
|
||||||
user = insert(:user, %{
|
user =
|
||||||
|
insert(:user, %{
|
||||||
name: "Link",
|
name: "Link",
|
||||||
email: "link@hyrule.com",
|
email: "link@hyrule.com",
|
||||||
password: "ilovezelda"
|
password: "ilovezelda"
|
||||||
@ -61,8 +62,6 @@ defmodule Chess.Features.ProfileTest do
|
|||||||
|> click(button("Update Profile"))
|
|> click(button("Update Profile"))
|
||||||
|
|
||||||
session
|
session
|
||||||
|> assert_has(
|
|> assert_has(css("[data-role='email-error']", text: "can't be blank"))
|
||||||
css("[data-role='email-error']", text: "can't be blank")
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user