digest_email_worker_test.exs (895B)
1 # Pleroma: A lightweight social networking server 2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> 3 # SPDX-License-Identifier: AGPL-3.0-only 4 5 defmodule Pleroma.DigestEmailWorkerTest do 6 use Pleroma.DataCase 7 import Pleroma.Factory 8 9 alias Pleroma.DigestEmailWorker 10 alias Pleroma.User 11 alias Pleroma.Web.CommonAPI 12 13 test "it sends digest emails" do 14 user = insert(:user) 15 16 date = 17 Timex.now() 18 |> Timex.shift(days: -10) 19 |> Timex.to_naive_datetime() 20 21 user2 = insert(:user, last_digest_emailed_at: date) 22 User.switch_email_notifications(user2, "digest", true) 23 CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}!"}) 24 25 DigestEmailWorker.perform() 26 27 assert_received {:email, email} 28 assert email.to == [{user2.name, user2.email}] 29 assert email.subject == "Your digest from #{Pleroma.Config.get(:instance)[:name]}" 30 end 31 end