Registration tests

This commit is contained in:
Alex Gleason 2020-10-11 21:38:01 -05:00
parent 28005563f0
commit 521e965884
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 23 additions and 5 deletions

View file

@ -1582,9 +1582,11 @@ defmodule Pleroma.User do
end end
def approve(%User{} = user) do def approve(%User{} = user) do
change(user, approval_pending: false) with chg <- change(user, approval_pending: false),
|> update_and_set_cache() {:ok, user} <- update_and_set_cache(chg) do
|> post_register_action() post_register_action(user)
{:ok, user}
end
end end
def update_notification_settings(%User{} = user, settings) do def update_notification_settings(%User{} = user, settings) do

View file

@ -34,8 +34,8 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
{:ok, _} <- {:ok, _} <-
user user
|> User.confirmation_changeset(need_confirmation: false) |> User.confirmation_changeset(need_confirmation: false)
|> User.update_and_set_cache() |> User.update_and_set_cache() do
|> User.post_register_action() do User.post_register_action(user)
redirect(conn, to: "/") redirect(conn, to: "/")
end end
end end

View file

@ -517,6 +517,22 @@ defmodule Pleroma.UserTest do
|> assert_email_sent() |> assert_email_sent()
end end
test "sends a pending approval email" do
clear_config([:instance, :account_approval_required], true)
{:ok, user} =
User.register_changeset(%User{}, @full_user_data)
|> User.register()
ObanHelpers.perform_all()
assert_email_sent(
from: Pleroma.Config.Helpers.sender(),
to: {user.name, user.email},
subject: "Your account is awaiting approval"
)
end
test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do
Pleroma.Config.put([:instance, :account_activation_required], true) Pleroma.Config.put([:instance, :account_activation_required], true)