diff options
author | lain <lain@soykaf.club> | 2019-08-24 15:48:33 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-08-24 15:48:33 +0200 |
commit | cc6c0b4ba6762e6a9b0a90c3dcda3f95283eb22a (patch) | |
tree | e80078875de15734e045f39e0bd9f82310961201 /test/tasks/digest_test.exs | |
parent | 0e2b5a3e6aed7947909c2a1ff1618403546f1572 (diff) | |
parent | bc78a875c86db42d67122cfb767f239a55dacbea (diff) | |
download | pleroma-cc6c0b4ba6762e6a9b0a90c3dcda3f95283eb22a.tar.gz |
Merge remote-tracking branch 'origin/develop' into sixohsix/pleroma-post_expiration
Diffstat (limited to 'test/tasks/digest_test.exs')
-rw-r--r-- | test/tasks/digest_test.exs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/tasks/digest_test.exs b/test/tasks/digest_test.exs new file mode 100644 index 000000000..4bfa1fb93 --- /dev/null +++ b/test/tasks/digest_test.exs @@ -0,0 +1,51 @@ +defmodule Mix.Tasks.Pleroma.DigestTest do + use Pleroma.DataCase + + import Pleroma.Factory + import Swoosh.TestAssertions + + alias Pleroma.Web.CommonAPI + + setup_all do + Mix.shell(Mix.Shell.Process) + + on_exit(fn -> + Mix.shell(Mix.Shell.IO) + end) + + :ok + end + + describe "pleroma.digest test" do + test "Sends digest to the given user" do + user1 = insert(:user) + user2 = insert(:user) + + Enum.each(0..10, fn i -> + {:ok, _activity} = + CommonAPI.post(user1, %{ + "status" => "hey ##{i} @#{user2.nickname}!" + }) + end) + + yesterday = + NaiveDateTime.add( + NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second), + -60 * 60 * 24, + :second + ) + + {:ok, yesterday_date} = Timex.format(yesterday, "%F", :strftime) + + :ok = Mix.Tasks.Pleroma.Digest.run(["test", user2.nickname, yesterday_date]) + + assert_receive {:mix_shell, :info, [message]} + assert message =~ "Digest email have been sent" + + assert_email_sent( + to: {user2.name, user2.email}, + html_body: ~r/here is what you've missed!/i + ) + end + end +end |