1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.ActivityTest do
10 test "returns an activity by it's AP id" do
11 activity = insert(:note_activity)
12 found_activity = Activity.get_by_ap_id(activity.data["id"])
14 assert activity == found_activity
17 test "returns activities by it's objects AP ids" do
18 activity = insert(:note_activity)
19 [found_activity] = Activity.get_all_create_by_object_ap_id(activity.data["object"]["id"])
21 assert activity == found_activity
24 test "returns the activity that created an object" do
25 activity = insert(:note_activity)
27 found_activity = Activity.get_create_by_object_ap_id(activity.data["object"]["id"])
29 assert activity == found_activity
33 %{id: id, data: %{"object" => %{"id" => object_ap_id}}} = activity = insert(:note_activity)
35 replies_count = activity.data["object"]["repliesCount"] || 0
36 expected_increase = replies_count + 1
37 Activity.increase_replies_count(object_ap_id)
38 %{data: %{"object" => %{"repliesCount" => actual_increase}}} = Activity.get_by_id(id)
39 assert expected_increase == actual_increase
40 expected_decrease = expected_increase - 1
41 Activity.decrease_replies_count(object_ap_id)
42 %{data: %{"object" => %{"repliesCount" => actual_decrease}}} = Activity.get_by_id(id)
43 assert expected_decrease == actual_decrease