summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-02-17 14:11:20 +0100
committerlain <lain@soykaf.club>2018-02-17 14:11:20 +0100
commit05ba6ca1b8a792dfaa8e636a964a09b766afb4d6 (patch)
treed5e036a132efc87620b8013391555348e4e9383e /test
parent5a371892a031ecc7359ff45d1119ae41a20f46dd (diff)
downloadpleroma-05ba6ca1b8a792dfaa8e636a964a09b766afb4d6.tar.gz
pleroma-05ba6ca1b8a792dfaa8e636a964a09b766afb4d6.zip
Do some transmogrifying for the output.
Diffstat (limited to 'test')
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 269429359..76dc6d4ad 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -2,6 +2,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
use Pleroma.DataCase
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Activity
+ import Pleroma.Factory
+ alias Pleroma.Web.CommonAPI
describe "handle_incoming" do
test "it works for incoming notices" do
@@ -29,4 +31,42 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert object["attributedTo"] == "http://mastodon.example.org/users/admin"
end
end
+
+ describe "prepare outgoing" do
+ test "it turns mentions into tags" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "hey, @#{other_user.nickname}, how are ya?"})
+
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+ object = modified["object"]
+
+ expected_tag = %{
+ "href" => other_user.ap_id,
+ "name" => "@#{other_user.nickname}",
+ "type" => "mention"
+ }
+
+ assert Enum.member?(object["tags"], expected_tag)
+ end
+
+ test "it adds the json-ld context" do
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+ assert modified["@context"] == "https://www.w3.org/ns/activitystreams"
+ end
+
+ test "it sets the 'attributedTo' property to the actor of the object if it doesn't have one" do
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+ assert modified["object"]["actor"] == modified["object"]["attributedTo"]
+ end
+ end
end