diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2018-12-18 17:13:52 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2018-12-18 17:22:46 +0300 |
commit | b096e30cffc79a4adf12be88da412a290cd0d190 (patch) | |
tree | b7f827b07911eacf731f289da54d73128c1e7cf2 /test/user_test.exs | |
parent | aed0f902871524ecc1db0d8c088ce5939e7c685a (diff) | |
download | pleroma-b096e30cffc79a4adf12be88da412a290cd0d190.tar.gz |
[#114] Added email confirmation resend action. Added tests
for registration, authentication, email confirmation, confirmation resending.
Made admin methods create confirmed users.
Diffstat (limited to 'test/user_test.exs')
-rw-r--r-- | test/user_test.exs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/user_test.exs b/test/user_test.exs index 1e73770df..b4d8174c6 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -177,6 +177,48 @@ defmodule Pleroma.UserTest do end end + describe "user registration, with :account_activation_required" do + @full_user_data %{ + bio: "A guy", + name: "my name", + nickname: "nick", + password: "test", + password_confirmation: "test", + email: "email@example.com" + } + + setup do + setting = Pleroma.Config.get([:instance, :account_activation_required]) + + unless setting do + Pleroma.Config.put([:instance, :account_activation_required], true) + on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end) + end + + :ok + end + + test "it creates unconfirmed user" do + changeset = User.register_changeset(%User{}, @full_user_data) + assert changeset.valid? + + {:ok, user} = Repo.insert(changeset) + + assert user.info.confirmation_pending + assert user.info.confirmation_token + end + + test "it creates confirmed user if :confirmed option is given" do + changeset = User.register_changeset(%User{}, @full_user_data, confirmed: true) + assert changeset.valid? + + {:ok, user} = Repo.insert(changeset) + + refute user.info.confirmation_pending + refute user.info.confirmation_token + end + end + describe "get_or_fetch/1" do test "gets an existing user by nickname" do user = insert(:user) |