diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/support/factory.ex | 4 | ||||
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index af8e58bd1..3fc9cf710 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -22,7 +22,9 @@ defmodule Pleroma.Factory do "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id, "actor" => user.ap_id, "to" => ["https://www.w3.org/ns/activitystreams#Public"], - "published_at" => DateTime.utc_now() |> DateTime.to_iso8601 + "published_at" => DateTime.utc_now() |> DateTime.to_iso8601, + "likes" => [], + "like_count" => 0 } %Pleroma.Object{ diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 570120484..203dcaec2 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -142,6 +142,26 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end end + describe "unliking" do + test "unliking a previously liked object" do + note_activity = insert(:note_activity) + object = Object.get_by_ap_id(note_activity.data["object"]["id"]) + user = insert(:user) + + # Unliking something that hasn't been liked does nothing + {:ok, object} = ActivityPub.unlike(user, object) + assert object.data["like_count"] == 0 + + {:ok, like_activity, object} = ActivityPub.like(user, object) + assert object.data["like_count"] == 1 + + {:ok, object} = ActivityPub.unlike(user, object) + assert object.data["like_count"] == 0 + + assert Repo.get(Activity, like_activity.id) == nil + end + end + describe "uploading files" do test "copies the file to the configured folder" do file = %Plug.Upload{content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an_image.jpg"} |