summaryrefslogtreecommitdiff
path: root/test/web/activity_pub
diff options
context:
space:
mode:
authorlambda <lain@soykaf.club>2019-05-07 14:43:21 +0000
committerlambda <lain@soykaf.club>2019-05-07 14:43:21 +0000
commit238dd72fad2452a8da594e68b8e6c80d709587e8 (patch)
tree050a8e55ae39047e197b0e84c9fed8bacaf91545 /test/web/activity_pub
parent6518644db1d31f2b30b95fa0899b3751bc330d56 (diff)
parentc42ded13a2caa02f3f5aa00accce69b183546f9e (diff)
downloadpleroma-238dd72fad2452a8da594e68b8e6c80d709587e8.tar.gz
pleroma-238dd72fad2452a8da594e68b8e6c80d709587e8.zip
Merge branch 'conversations_three' into 'develop'
Conversations once more. See merge request pleroma/pleroma!1119
Diffstat (limited to 'test/web/activity_pub')
-rw-r--r--test/web/activity_pub/activity_pub_test.exs75
1 files changed, 66 insertions, 9 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index f8e987e58..1e056b7ee 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -22,6 +22,28 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
:ok
end
+ describe "streaming out participations" do
+ test "it streams them out" do
+ user = insert(:user)
+ {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+
+ {:ok, conversation} = Pleroma.Conversation.create_or_bump_for(activity)
+
+ participations =
+ conversation.participations
+ |> Repo.preload(:user)
+
+ with_mock Pleroma.Web.Streamer,
+ stream: fn _, _ -> nil end do
+ ActivityPub.stream_out_participations(conversation.participations)
+
+ Enum.each(participations, fn participation ->
+ assert called(Pleroma.Web.Streamer.stream("participation", participation))
+ end)
+ end
+ end
+ end
+
describe "fetching restricted by visibility" do
test "it restricts by the appropriate visibility" do
user = insert(:user)
@@ -130,9 +152,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
test "doesn't drop activities with content being null" do
+ user = insert(:user)
+
data = %{
- "ok" => true,
+ "actor" => user.ap_id,
+ "to" => [],
"object" => %{
+ "actor" => user.ap_id,
+ "to" => [],
+ "type" => "Note",
"content" => nil
}
}
@@ -148,8 +176,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
test "inserts a given map into the activity database, giving it an id if it has none." do
+ user = insert(:user)
+
data = %{
- "ok" => true
+ "actor" => user.ap_id,
+ "to" => [],
+ "object" => %{
+ "actor" => user.ap_id,
+ "to" => [],
+ "type" => "Note",
+ "content" => "hey"
+ }
}
{:ok, %Activity{} = activity} = ActivityPub.insert(data)
@@ -159,9 +196,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
given_id = "bla"
data = %{
- "ok" => true,
"id" => given_id,
- "context" => "blabla"
+ "actor" => user.ap_id,
+ "to" => [],
+ "context" => "blabla",
+ "object" => %{
+ "actor" => user.ap_id,
+ "to" => [],
+ "type" => "Note",
+ "content" => "hey"
+ }
}
{:ok, %Activity{} = activity} = ActivityPub.insert(data)
@@ -172,26 +216,39 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
test "adds a context when none is there" do
+ user = insert(:user)
+
data = %{
- "id" => "some_id",
+ "actor" => user.ap_id,
+ "to" => [],
"object" => %{
- "id" => "object_id"
+ "actor" => user.ap_id,
+ "to" => [],
+ "type" => "Note",
+ "content" => "hey"
}
}
{:ok, %Activity{} = activity} = ActivityPub.insert(data)
+ object = Pleroma.Object.normalize(activity)
assert is_binary(activity.data["context"])
- assert is_binary(activity.data["object"]["context"])
+ assert is_binary(object.data["context"])
assert activity.data["context_id"]
- assert activity.data["object"]["context_id"]
+ assert object.data["context_id"]
end
test "adds an id to a given object if it lacks one and is a note and inserts it to the object database" do
+ user = insert(:user)
+
data = %{
+ "actor" => user.ap_id,
+ "to" => [],
"object" => %{
+ "actor" => user.ap_id,
+ "to" => [],
"type" => "Note",
- "ok" => true
+ "content" => "hey"
}
}