Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2KB

  1. defmodule Mix.Tasks.Pleroma.DigestTest do
  2. use Pleroma.DataCase
  3. import Pleroma.Factory
  4. import Swoosh.TestAssertions
  5. alias Pleroma.Tests.ObanHelpers
  6. alias Pleroma.Web.CommonAPI
  7. setup_all do
  8. Mix.shell(Mix.Shell.Process)
  9. on_exit(fn ->
  10. Mix.shell(Mix.Shell.IO)
  11. end)
  12. :ok
  13. end
  14. describe "pleroma.digest test" do
  15. test "Sends digest to the given user" do
  16. user1 = insert(:user)
  17. user2 = insert(:user)
  18. Enum.each(0..10, fn i ->
  19. {:ok, _activity} =
  20. CommonAPI.post(user1, %{
  21. "status" => "hey ##{i} @#{user2.nickname}!"
  22. })
  23. end)
  24. yesterday =
  25. NaiveDateTime.add(
  26. NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second),
  27. -60 * 60 * 24,
  28. :second
  29. )
  30. {:ok, yesterday_date} = Timex.format(yesterday, "%F", :strftime)
  31. :ok = Mix.Tasks.Pleroma.Digest.run(["test", user2.nickname, yesterday_date])
  32. ObanHelpers.perform_all()
  33. assert_receive {:mix_shell, :info, [message]}
  34. assert message =~ "Digest email have been sent"
  35. assert_email_sent(
  36. to: {user2.name, user2.email},
  37. html_body: ~r/here is what you've missed!/i
  38. )
  39. end
  40. end
  41. end