mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2025-01-30 13:31:13 +00:00
Add test to make sure user emails are really unique
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
e837d12c55
commit
b3be9088fe
1 changed files with 38 additions and 1 deletions
|
@ -275,6 +275,44 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||||
@user_creation.username
|
@user_creation.username
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "create_user/3 doesn't allow two users with the same email", %{conn: conn} do
|
||||||
|
mutation = """
|
||||||
|
mutation {
|
||||||
|
createUser(
|
||||||
|
email: "#{@user_creation.email}",
|
||||||
|
password: "#{@user_creation.password}",
|
||||||
|
) {
|
||||||
|
id,
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
res =
|
||||||
|
conn
|
||||||
|
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||||
|
|
||||||
|
assert json_response(res, 200)["data"]["createUser"]["email"] == @user_creation.email
|
||||||
|
|
||||||
|
mutation = """
|
||||||
|
mutation {
|
||||||
|
createUser(
|
||||||
|
email: "#{@user_creation.email}",
|
||||||
|
password: "#{@user_creation.password}",
|
||||||
|
) {
|
||||||
|
id,
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
res =
|
||||||
|
conn
|
||||||
|
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||||
|
|
||||||
|
assert hd(json_response(res, 200)["errors"])["message"] == "This email is already used."
|
||||||
|
end
|
||||||
|
|
||||||
test "register_person/3 doesn't register a profile from an unknown email", context do
|
test "register_person/3 doesn't register a profile from an unknown email", context do
|
||||||
mutation = """
|
mutation = """
|
||||||
mutation {
|
mutation {
|
||||||
|
@ -429,7 +467,6 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Resolver: Validate an user" do
|
describe "Resolver: Validate an user" do
|
||||||
@valid_actor_params %{email: "test@test.tld", password: "testest"}
|
|
||||||
test "test validate_user/3 validates an user", context do
|
test "test validate_user/3 validates an user", context do
|
||||||
{:ok, %User{} = user} = Users.register(@valid_actor_params)
|
{:ok, %User{} = user} = Users.register(@valid_actor_params)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue