Refactor User.post_register_action/1 emails
[akkoma] / test / emails / mailer_test.exs
index ae5effb7ad1a1cf6b5cb6b79e005bd6c2923245e..9e232d2a0b8fab77b33e40633d377c0e3d11eeb8 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Emails.MailerTest do
@@ -14,12 +14,12 @@ defmodule Pleroma.Emails.MailerTest do
     subject: "Pleroma test email",
     to: [{"Test User", "user1@example.com"}]
   }
-
-  clear_config([Pleroma.Emails.Mailer, :enabled])
+  setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
 
   test "not send email when mailer is disabled" do
-    Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
+    clear_config([Pleroma.Emails.Mailer, :enabled], false)
     Mailer.deliver(@email)
+    :timer.sleep(100)
 
     refute_email_sent(
       from: {"Pleroma", "noreply@example.com"},
@@ -31,6 +31,7 @@ defmodule Pleroma.Emails.MailerTest do
 
   test "send email" do
     Mailer.deliver(@email)
+    :timer.sleep(100)
 
     assert_email_sent(
       from: {"Pleroma", "noreply@example.com"},
@@ -42,6 +43,7 @@ defmodule Pleroma.Emails.MailerTest do
 
   test "perform" do
     Mailer.perform(:deliver_async, @email, [])
+    :timer.sleep(100)
 
     assert_email_sent(
       from: {"Pleroma", "noreply@example.com"},