TwitterAPI: test pending approval user email

This commit is contained in:
Alex Gleason 2020-10-12 15:24:53 -05:00
parent bb8c0614ef
commit 9ddc292ca8
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -80,13 +80,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end end
test "it sends an admin email if :account_approval_required is specified in instance config" do test "it sends an admin email if :account_approval_required is specified in instance config" do
admin = insert(:user, is_admin: true) clear_config([:instance, :account_approval_required], true)
setting = Pleroma.Config.get([:instance, :account_approval_required])
unless setting do admin = insert(:user, is_admin: true)
Pleroma.Config.put([:instance, :account_approval_required], true)
on_exit(fn -> Pleroma.Config.put([:instance, :account_approval_required], setting) end)
end
data = %{ data = %{
:username => "lain", :username => "lain",
@ -103,15 +99,24 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert user.approval_pending assert user.approval_pending
email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user) user_email = Pleroma.Emails.UserEmail.approval_pending_email(user)
admin_email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
notify_email = Pleroma.Config.get([:instance, :notify_email]) notify_email = Pleroma.Config.get([:instance, :notify_email])
instance_name = Pleroma.Config.get([:instance, :name]) instance_name = Pleroma.Config.get([:instance, :name])
# User approval email
Swoosh.TestAssertions.assert_email_sent(
from: {instance_name, notify_email},
to: {user.name, user.email},
html_body: user_email.html_body
)
# Admin email
Swoosh.TestAssertions.assert_email_sent( Swoosh.TestAssertions.assert_email_sent(
from: {instance_name, notify_email}, from: {instance_name, notify_email},
to: {admin.name, admin.email}, to: {admin.name, admin.email},
html_body: email.html_body html_body: admin_email.html_body
) )
end end