aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-05-03 17:39:12 +0200
committerRoger Braun <roger@rogerbraun.net>2017-05-03 17:39:12 +0200
commit138641589dffc6ba69710ec15c690b50769f07b4 (patch)
treeb47cf33827cfa9263d84f0d6c4896278e104bf11 /test
parentdf71c142cfadaae8866303768bca00c343b8bed1 (diff)
downloadpleroma-138641589dffc6ba69710ec15c690b50769f07b4.tar.gz
OStatus announce representer.
Diffstat (limited to 'test')
-rw-r--r--test/web/ostatus/activity_representer_test.exs45
1 files changed, 44 insertions, 1 deletions
diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs
index 4cf73427b..d3c32e938 100644
--- a/test/web/ostatus/activity_representer_test.exs
+++ b/test/web/ostatus/activity_representer_test.exs
@@ -2,7 +2,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
use Pleroma.DataCase
alias Pleroma.Web.OStatus.ActivityRepresenter
- alias Pleroma.{User, Activity}
+ alias Pleroma.{User, Activity, Object}
alias Pleroma.Web.ActivityPub.ActivityPub
import Pleroma.Factory
@@ -73,6 +73,49 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
assert clean(res) == clean(expected)
end
+ test "an announce activity" do
+ note = insert(:note_activity)
+ user = insert(:user)
+ object = Object.get_cached_by_ap_id(note.data["object"]["id"])
+
+ {:ok, announce, object} = ActivityPub.announce(user, object)
+
+ announce = Repo.get(Activity, announce.id)
+
+ note_user = User.get_cached_by_ap_id(note.data["actor"])
+ note = Repo.get(Activity, note.id)
+ note_xml = ActivityRepresenter.to_simple_form(note, note_user)
+ |> :xmerl.export_simple_content(:xmerl_xml)
+ |> IO.iodata_to_binary
+
+ updated_at = announce.updated_at
+ |> NaiveDateTime.to_iso8601
+ inserted_at = announce.inserted_at
+ |> NaiveDateTime.to_iso8601
+
+ expected = """
+ <activity:verb>http://activitystrea.ms/schema/1.0/share</activity:verb>
+ <id>#{announce.data["id"]}</id>
+ <title>#{user.nickname} repeated a notice</title>
+ <content type="html">RT #{note.data["object"]["content"]}</content>
+ <published>#{inserted_at}</published>
+ <updated>#{updated_at}</updated>
+ <ostatus:conversation>#{announce.data["context"]}</ostatus:conversation>
+ <link href="#{announce.data["context"]}" rel="ostatus:conversation" />
+ <thr:in-reply-to ref="#{note.data["object"]["id"]}" />
+ <activity:object>
+ #{note_xml}
+ </activity:object>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{note.data["actor"]}"/>
+ """
+
+ announce_xml = ActivityRepresenter.to_simple_form(announce, user)
+ |> :xmerl.export_simple_content(:xmerl_xml)
+ |> IO.iodata_to_binary
+
+ assert clean(expected) == clean(announce_xml)
+ end
+
test "a like activity" do
note = insert(:note)
user = insert(:user)