+ assert activity == Utils.fetch_latest_follow(follower, followed)
+ end
+ end
+
+ describe "following / unfollowing" do
+ test "creates a follow activity" do
+ follower = insert(:user)
+ followed = insert(:user)
+
+ {:ok, activity} = ActivityPub.follow(follower, followed)
+ assert activity.data["type"] == "Follow"
+ assert activity.data["actor"] == follower.ap_id
+ assert activity.data["object"] == followed.ap_id
+ end
+
+ test "creates an undo activity for the last follow" do
+ follower = insert(:user)
+ followed = insert(:user)
+
+ {:ok, follow_activity} = ActivityPub.follow(follower, followed)
+ {:ok, activity} = ActivityPub.unfollow(follower, followed)
+
+ assert activity.data["type"] == "Undo"
+ assert activity.data["actor"] == follower.ap_id
+ assert activity.data["object"] == follow_activity.data["id"]
+ end
+ end
+
+ describe "deletion" do
+ test "it creates a delete activity and deletes the original object" do
+ note = insert(:note_activity)
+ object = Object.get_by_ap_id(note.data["object"]["id"])
+ {:ok, delete} = ActivityPub.delete(object)
+
+ assert delete.data["type"] == "Delete"
+ assert delete.data["actor"] == note.data["actor"]
+ assert delete.data["object"] == note.data["object"]["id"]
+
+ assert Repo.get(Activity, delete.id) != nil
+
+ assert Repo.get(Object, object.id) == nil