Merge branch 'bug/make-user-email-unique' into 'master'

Add test to make sure user emails are really unique

Closes #181

See merge request framasoft/mobilizon!211
This commit is contained in:
Thomas Citharel 2019-10-01 09:39:25 +02:00
commit d5a15b8a99

View file

@ -275,6 +275,44 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
@user_creation.username
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
mutation = """
mutation {
@ -429,7 +467,6 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
end
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
{:ok, %User{} = user} = Users.register(@valid_actor_params)