summaryrefslogtreecommitdiff
path: root/test/daemons/digest_email_daemon_test.exs
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-09-16 14:40:17 +0300
committerMaxim Filippov <colixer@gmail.com>2019-09-16 14:40:17 +0300
commit219dca1b00a60805545dd3de433de285cc944af5 (patch)
treef8ffd4f93bf3f7bcd7ce0b789a18fb425134781a /test/daemons/digest_email_daemon_test.exs
parent736165c082d34ef4d52367ea8315c228a1df3944 (diff)
parent409e701ab849475c81073d80a973487d67cadaae (diff)
downloadpleroma-219dca1b00a60805545dd3de433de285cc944af5.tar.gz
pleroma-219dca1b00a60805545dd3de433de285cc944af5.zip
Merge branch 'develop' into feature/return-total-for-reports
Diffstat (limited to 'test/daemons/digest_email_daemon_test.exs')
-rw-r--r--test/daemons/digest_email_daemon_test.exs35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/daemons/digest_email_daemon_test.exs b/test/daemons/digest_email_daemon_test.exs
new file mode 100644
index 000000000..3168f3b9a
--- /dev/null
+++ b/test/daemons/digest_email_daemon_test.exs
@@ -0,0 +1,35 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.DigestEmailDaemonTest do
+ use Pleroma.DataCase
+ import Pleroma.Factory
+
+ alias Pleroma.Daemons.DigestEmailDaemon
+ alias Pleroma.Tests.ObanHelpers
+ alias Pleroma.User
+ alias Pleroma.Web.CommonAPI
+
+ test "it sends digest emails" do
+ user = insert(:user)
+
+ date =
+ Timex.now()
+ |> Timex.shift(days: -10)
+ |> Timex.to_naive_datetime()
+
+ user2 = insert(:user, last_digest_emailed_at: date)
+ User.switch_email_notifications(user2, "digest", true)
+ CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}!"})
+
+ DigestEmailDaemon.perform()
+ ObanHelpers.perform_all()
+ # Performing job(s) enqueued at previous step
+ ObanHelpers.perform_all()
+
+ assert_received {:email, email}
+ assert email.to == [{user2.name, user2.email}]
+ assert email.subject == "Your digest from #{Pleroma.Config.get(:instance)[:name]}"
+ end
+end