summaryrefslogtreecommitdiff
path: root/test/daemons
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-09-16 19:44:06 +0300
committerMaxim Filippov <colixer@gmail.com>2019-09-16 19:44:06 +0300
commitdf15ed13d15db5b5a371345fcb9968b5af4100af (patch)
tree02f8834a25733ed7ee02fa9aa4dd66b606f78030 /test/daemons
parentd1abf7a3585e4bc1ebea4f615ae2e149d5a56918 (diff)
parenta58f29b826333c1ecb0907228f0e087a3ecd9778 (diff)
downloadpleroma-df15ed13d15db5b5a371345fcb9968b5af4100af.tar.gz
pleroma-df15ed13d15db5b5a371345fcb9968b5af4100af.zip
Merge branch 'develop' into feature/moderation-log-filters
Diffstat (limited to 'test/daemons')
-rw-r--r--test/daemons/activity_expiration_daemon_test.exs17
-rw-r--r--test/daemons/digest_email_daemon_test.exs35
-rw-r--r--test/daemons/scheduled_activity_daemon_test.exs19
3 files changed, 71 insertions, 0 deletions
diff --git a/test/daemons/activity_expiration_daemon_test.exs b/test/daemons/activity_expiration_daemon_test.exs
new file mode 100644
index 000000000..31f4a70a6
--- /dev/null
+++ b/test/daemons/activity_expiration_daemon_test.exs
@@ -0,0 +1,17 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.ActivityExpirationWorkerTest do
+ use Pleroma.DataCase
+ alias Pleroma.Activity
+ import Pleroma.Factory
+
+ test "deletes an activity" do
+ activity = insert(:note_activity)
+ expiration = insert(:expiration_in_the_past, %{activity_id: activity.id})
+ Pleroma.Daemons.ActivityExpirationDaemon.perform(:execute, expiration.id)
+
+ refute Repo.get(Activity, activity.id)
+ end
+end
diff --git a/test/daemons/digest_email_daemon_test.exs b/test/daemons/digest_email_daemon_test.exs
new file mode 100644
index 000000000..3168f3b9a
--- /dev/null
+++ b/test/daemons/digest_email_daemon_test.exs
@@ -0,0 +1,35 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.DigestEmailDaemonTest do
+ use Pleroma.DataCase
+ import Pleroma.Factory
+
+ alias Pleroma.Daemons.DigestEmailDaemon
+ 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}!"})
+
+ DigestEmailDaemon.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
diff --git a/test/daemons/scheduled_activity_daemon_test.exs b/test/daemons/scheduled_activity_daemon_test.exs
new file mode 100644
index 000000000..32820b2b7
--- /dev/null
+++ b/test/daemons/scheduled_activity_daemon_test.exs
@@ -0,0 +1,19 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.ScheduledActivityDaemonTest do
+ use Pleroma.DataCase
+ alias Pleroma.ScheduledActivity
+ import Pleroma.Factory
+
+ test "creates a status from the scheduled activity" do
+ user = insert(:user)
+ scheduled_activity = insert(:scheduled_activity, user: user, params: %{status: "hi"})
+ Pleroma.Daemons.ScheduledActivityDaemon.perform(:execute, scheduled_activity.id)
+
+ refute Repo.get(ScheduledActivity, scheduled_activity.id)
+ activity = Repo.all(Pleroma.Activity) |> Enum.find(&(&1.actor == user.ap_id))
+ assert Pleroma.Object.normalize(activity).data["content"] == "hi"
+ end
+end