Add type to rel=self link in feed.
[akkoma] / test / web / ostatus / activity_representer_test.exs
index 6cea9cff0e4658c8d8f06b4d382cbb15acbff7ae..439c733d7e33e17a0f0978bfa9001cbf08b4ca58 100644 (file)
@@ -18,13 +18,14 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
     expected = """
     <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
     <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
-    <id>#{note_activity.data["id"]}</id>
+    <id>#{note_activity.data["object"]["id"]}</id>
     <title>New note by #{user.nickname}</title>
     <content type="html">#{note_activity.data["object"]["content"]}</content>
     <published>#{inserted_at}</published>
     <updated>#{updated_at}</updated>
     <ostatus:conversation>#{note_activity.data["context"]}</ostatus:conversation>
     <link href="#{note_activity.data["context"]}" rel="ostatus:conversation" />
+    <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
     """
 
     tuple = ActivityRepresenter.to_simple_form(note_activity, user)
@@ -34,6 +35,43 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
     assert clean(res) == clean(expected)
   end
 
+  test "a reply note" do
+    note = insert(:note_activity)
+    answer = insert(:note_activity)
+    object = answer.data["object"]
+    object = Map.put(object, "inReplyTo", note.data["object"]["id"])
+
+    data = %{answer.data | "object" => object}
+    answer = %{answer | data: data}
+
+    updated_at = answer.updated_at
+    |> NaiveDateTime.to_iso8601
+    inserted_at = answer.inserted_at
+    |> NaiveDateTime.to_iso8601
+
+    user = User.get_cached_by_ap_id(answer.data["actor"])
+
+    expected = """
+    <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
+    <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
+    <id>#{answer.data["object"]["id"]}</id>
+    <title>New note by #{user.nickname}</title>
+    <content type="html">#{answer.data["object"]["content"]}</content>
+    <published>#{inserted_at}</published>
+    <updated>#{updated_at}</updated>
+    <ostatus:conversation>#{answer.data["context"]}</ostatus:conversation>
+    <link href="#{answer.data["context"]}" rel="ostatus:conversation" />
+    <thr:in-reply-to ref="#{note.data["object"]["id"]}" />
+    <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
+    """
+
+    tuple = ActivityRepresenter.to_simple_form(answer, user)
+
+    res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
+
+    assert clean(res) == clean(expected)
+  end
+
   test "an unknown activity" do
     tuple = ActivityRepresenter.to_simple_form(%Activity{}, nil)
     assert is_nil(tuple)