aboutsummaryrefslogtreecommitdiff
path: root/test/support
diff options
context:
space:
mode:
authorsxsdv1 <sxsdv1@gmail.com>2019-01-12 17:52:30 +0100
committersxsdv1 <sxsdv1@gmail.com>2019-01-12 20:24:32 +0100
commit1eb7318831e7239ec929457f6298fb05cb461b43 (patch)
treecb6e6206c5818a48d5349a4c2c1d4dcb20f31bdc /test/support
parent19b6a8239387869c69c6885044ee488d097b723f (diff)
downloadpleroma-1eb7318831e7239ec929457f6298fb05cb461b43.tar.gz
Prepare all types objects before serialising
Activities returned from inbox can include other types of objects like Article
Diffstat (limited to 'test/support')
-rw-r--r--test/support/factory.ex25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex
index 57fa4a79d..4ac77981a 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -57,6 +57,11 @@ defmodule Pleroma.Factory do
%Pleroma.Object{data: Map.merge(data, %{"to" => [user2.ap_id]})}
end
+ def article_factory do
+ note_factory()
+ |> Map.put("type", "Article")
+ end
+
def tombstone_factory do
data = %{
"type" => "Tombstone",
@@ -110,6 +115,26 @@ defmodule Pleroma.Factory do
}
end
+ def article_activity_factory do
+ article = insert(:article)
+
+ data = %{
+ "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
+ "type" => "Create",
+ "actor" => article.data["actor"],
+ "to" => article.data["to"],
+ "object" => article.data,
+ "published" => DateTime.utc_now() |> DateTime.to_iso8601(),
+ "context" => article.data["context"]
+ }
+
+ %Pleroma.Activity{
+ data: data,
+ actor: data["actor"],
+ recipients: data["to"]
+ }
+ end
+
def announce_activity_factory do
note_activity = insert(:note_activity)
user = insert(:user)