akkoma/test/web/digest_email_worker_test.exs
Ivan Tashkinov 256ff09aa8 [#1149] Merge remote-tracking branch 'remotes/upstream/develop' into 1149-oban-job-queue
# Conflicts:
#	lib/pleroma/application.ex
#	lib/pleroma/scheduled_activity_worker.ex
#	lib/pleroma/web/federator/retry_queue.ex
#	lib/pleroma/web/oauth/token/clean_worker.ex
#	test/user_test.exs
#	test/web/federator_test.exs
2019-08-22 20:59:58 +03:00

35 lines
1 KiB
Elixir

# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.DigestEmailWorkerTest do
use Pleroma.DataCase
import Pleroma.Factory
alias Pleroma.DigestEmailWorker
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}!"})
DigestEmailWorker.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