summaryrefslogtreecommitdiff
path: root/test/support
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2021-02-03 09:31:38 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2021-02-03 09:31:38 +0300
commit4e14945670bac15a6e183eb8c552d6e0669713ac (patch)
treec25db5253cafb81dbfa31cc779ffae8e07806b7e /test/support
parentcf4765af4098098fa4d6996193432bd19c439a75 (diff)
parentfd2477dfba1f167c7519a029bedd7ae6884a9f1d (diff)
downloadpleroma-4e14945670bac15a6e183eb8c552d6e0669713ac.tar.gz
pleroma-4e14945670bac15a6e183eb8c552d6e0669713ac.zip
Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework
# Conflicts: # CHANGELOG.md # lib/pleroma/web/activity_pub/activity_pub.ex
Diffstat (limited to 'test/support')
-rw-r--r--test/support/factory.ex31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex
index bf9592064..436e19409 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -104,6 +104,37 @@ defmodule Pleroma.Factory do
}
end
+ def attachment_note_factory(attrs \\ %{}) do
+ user = attrs[:user] || insert(:user)
+ {length, attrs} = Map.pop(attrs, :length, 1)
+
+ data = %{
+ "attachment" =>
+ Stream.repeatedly(fn -> attachment_data(user.ap_id, attrs[:href]) end)
+ |> Enum.take(length)
+ }
+
+ build(:note, Map.put(attrs, :data, data))
+ end
+
+ defp attachment_data(ap_id, href) do
+ href = href || sequence(:href, &"#{Pleroma.Web.Endpoint.url()}/media/#{&1}.jpg")
+
+ %{
+ "url" => [
+ %{
+ "href" => href,
+ "type" => "Link",
+ "mediaType" => "image/jpeg"
+ }
+ ],
+ "name" => "some name",
+ "type" => "Document",
+ "actor" => ap_id,
+ "mediaType" => "image/jpeg"
+ }
+ end
+
def audio_factory(attrs \\ %{}) do
text = sequence(:text, &"lain radio episode #{&1}")