From a41aa4e4898660fffb9a54070d16e2c3a5373d71 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 7 May 2017 14:45:37 +0200 Subject: Federate follow salmons. --- test/web/ostatus/activity_representer_test.exs | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'test') diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 12c9bbaa2..af936b57c 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -124,6 +124,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do user = insert(:user) {:ok, like, _note} = ActivityPub.like(user, note) + # TODO: Are these the correct dates? updated_at = like.updated_at |> NaiveDateTime.to_iso8601 inserted_at = like.inserted_at @@ -155,6 +156,49 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do assert clean(res) == clean(expected) end + test "a follow activity" do + follower = insert(:user) + followed = insert(:user) + {:ok, activity} = ActivityPub.insert(%{ + "type" => "Follow", + "actor" => follower.ap_id, + "object" => followed.ap_id, + "to" => [followed.ap_id] + }) + + + # TODO: Are these the correct dates? + updated_at = activity.updated_at + |> NaiveDateTime.to_iso8601 + inserted_at = activity.inserted_at + |> NaiveDateTime.to_iso8601 + + tuple = ActivityRepresenter.to_simple_form(activity, follower) + + refute is_nil(tuple) + + res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary + + expected = """ + http://activitystrea.ms/schema/1.0/activity + http://activitystrea.ms/schema/1.0/follow + #{activity.data["id"]} + #{follower.nickname} started following #{activity.data["object"]} + #{follower.nickname} started following #{activity.data["object"]} + #{inserted_at} + #{updated_at} + + http://activitystrea.ms/schema/1.0/person + #{activity.data["object"]} + #{activity.data["object"]} + + + + """ + + assert clean(res) == clean(expected) + end + test "an unknown activity" do tuple = ActivityRepresenter.to_simple_form(%Activity{}, nil) assert is_nil(tuple) -- cgit v1.2.3