1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.DigestEmailDaemonTest do
9 alias Pleroma.Daemons.DigestEmailDaemon
10 alias Pleroma.Tests.ObanHelpers
12 alias Pleroma.Web.CommonAPI
14 test "it sends digest emails" do
19 |> Timex.shift(days: -10)
20 |> Timex.to_naive_datetime()
22 user2 = insert(:user, last_digest_emailed_at: date)
23 User.switch_email_notifications(user2, "digest", true)
24 CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}!"})
26 DigestEmailDaemon.perform()
27 ObanHelpers.perform_all()
28 # Performing job(s) enqueued at previous step
29 ObanHelpers.perform_all()
31 assert_received {:email, email}
32 assert email.to == [{user2.name, user2.email}]
33 assert email.subject == "Your digest from #{Pleroma.Config.get(:instance)[:name]}"