diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-09-13 12:46:16 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-09-13 12:46:16 +0000 |
commit | 0d9609894f4f4557da2db62a33da1b8995c9e1d7 (patch) | |
tree | 76836a41a85f04c6cb07d4f1c6efba59013df649 /test/user_test.exs | |
parent | f884987ace0f060860b2ece0304cfba0708505a5 (diff) | |
parent | 7b5c81b3918b7ff99f00e72194075f43c3f81165 (diff) | |
download | pleroma-0d9609894f4f4557da2db62a33da1b8995c9e1d7.tar.gz |
Merge branch 'feature/change-email' into 'develop'
Add email change endpoint
Closes #1156
See merge request pleroma/pleroma!1580
Diffstat (limited to 'test/user_test.exs')
-rw-r--r-- | test/user_test.exs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/user_test.exs b/test/user_test.exs index a25b72f4e..ed8cdbe31 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -1614,4 +1614,31 @@ defmodule Pleroma.UserTest do assert User.user_info(other_user).following_count == 152 end end + + describe "change_email/2" do + setup do + [user: insert(:user)] + end + + test "blank email returns error", %{user: user} do + assert {:error, %{errors: [email: {"can't be blank", _}]}} = User.change_email(user, "") + assert {:error, %{errors: [email: {"can't be blank", _}]}} = User.change_email(user, nil) + end + + test "non unique email returns error", %{user: user} do + %{email: email} = insert(:user) + + assert {:error, %{errors: [email: {"has already been taken", _}]}} = + User.change_email(user, email) + end + + test "invalid email returns error", %{user: user} do + assert {:error, %{errors: [email: {"has invalid format", _}]}} = + User.change_email(user, "cofe") + end + + test "changes email", %{user: user} do + assert {:ok, %User{email: "cofe@cofe.party"}} = User.change_email(user, "cofe@cofe.party") + end + end end |