+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
+ note.data["actor"]
+ }"/>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
+ """
+
+ 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]
+ })
+
+ tuple = ActivityRepresenter.to_simple_form(activity, follower)
+
+ refute is_nil(tuple)
+
+ res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
+
+ expected = """
+ <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
+ <activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb>
+ <id>#{activity.data["id"]}</id>
+ <title>#{follower.nickname} started following #{activity.data["object"]}</title>
+ <content type="html"> #{follower.nickname} started following #{activity.data["object"]}</content>
+ <published>#{activity.data["published"]}</published>
+ <updated>#{activity.data["published"]}</updated>
+ <activity:object>
+ <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
+ <id>#{activity.data["object"]}</id>
+ <uri>#{activity.data["object"]}</uri>
+ </activity:object>
+ <link rel="self" type="application/atom+xml" href="#{activity.data["id"]}"/>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
+ activity.data["object"]
+ }"/>
+ """
+
+ assert clean(res) == clean(expected)
+ end
+
+ test "an unfollow activity" do
+ follower = insert(:user)
+ followed = insert(:user)
+ {:ok, _activity} = ActivityPub.follow(follower, followed)
+ {:ok, activity} = ActivityPub.unfollow(follower, followed)
+
+ tuple = ActivityRepresenter.to_simple_form(activity, follower)
+
+ refute is_nil(tuple)
+
+ res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
+
+ expected = """
+ <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
+ <activity:verb>http://activitystrea.ms/schema/1.0/unfollow</activity:verb>
+ <id>#{activity.data["id"]}</id>
+ <title>#{follower.nickname} stopped following #{followed.ap_id}</title>
+ <content type="html"> #{follower.nickname} stopped following #{followed.ap_id}</content>
+ <published>#{activity.data["published"]}</published>
+ <updated>#{activity.data["published"]}</updated>
+ <activity:object>
+ <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
+ <id>#{followed.ap_id}</id>
+ <uri>#{followed.ap_id}</uri>
+ </activity:object>
+ <link rel="self" type="application/atom+xml" href="#{activity.data["id"]}"/>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
+ followed.ap_id
+ }"/>
+ """
+
+ assert clean(res) == clean(expected)
+ end
+
+ test "a delete" do
+ user = insert(:user)
+
+ activity = %Activity{
+ data: %{
+ "id" => "ap_id",
+ "type" => "Delete",
+ "actor" => user.ap_id,
+ "object" => "some_id",
+ "published" => "2017-06-18T12:00:18+00:00"
+ }
+ }
+
+ tuple = ActivityRepresenter.to_simple_form(activity, nil)
+
+ refute is_nil(tuple)
+
+ res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
+
+ expected = """
+ <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
+ <activity:verb>http://activitystrea.ms/schema/1.0/delete</activity:verb>
+ <id>#{activity.data["object"]}</id>
+ <title>An object was deleted</title>
+ <content type="html">An object was deleted</content>
+ <published>#{activity.data["published"]}</published>
+ <updated>#{activity.data["published"]}</updated>