summaryrefslogtreecommitdiff
path: root/test/daemons/digest_email_daemon_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-09-30 13:57:54 +0200
committerlain <lain@soykaf.club>2019-09-30 13:57:54 +0200
commitb923842e96e821afeb7bbfa0d098b9c5698281c5 (patch)
tree37d84255d7b97fc411f5c78378565a8f205a2120 /test/daemons/digest_email_daemon_test.exs
parent6fe2f554c36be1ef03ac1d1104a78d0686f48a26 (diff)
parent74d8fadf3745a4b4203c2cead35b741554ccc439 (diff)
downloadpleroma-b923842e96e821afeb7bbfa0d098b9c5698281c5.tar.gz
pleroma-b923842e96e821afeb7bbfa0d098b9c5698281c5.zip
Merge remote-tracking branch 'origin/develop' into reactions
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