X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fsupport%2Ffactory.ex;h=7191150031c703e6565b2746310fd3fe0770522e;hb=c623b4324deaf236334a0f77a81435b5bffadf3c;hp=8f638b98f2a262a14942ae35bef24774a2d49c81;hpb=bedabf7db21d14ad4e92f107175328ddb147e64f;p=akkoma
diff --git a/test/support/factory.ex b/test/support/factory.ex
index 8f638b98f..719115003 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Factory do
@@ -31,7 +31,8 @@ defmodule Pleroma.Factory do
nickname: sequence(:nickname, &"nick#{&1}"),
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: sequence(:bio, &"Tester Number #{&1}"),
- info: %{}
+ info: %{},
+ last_digest_emailed_at: NaiveDateTime.utc_now()
}
%{
@@ -142,6 +143,25 @@ defmodule Pleroma.Factory do
|> Map.merge(attrs)
end
+ defp expiration_offset_by_minutes(attrs, minutes) do
+ scheduled_at =
+ NaiveDateTime.utc_now()
+ |> NaiveDateTime.add(:timer.minutes(minutes), :millisecond)
+ |> NaiveDateTime.truncate(:second)
+
+ %Pleroma.ActivityExpiration{}
+ |> Map.merge(attrs)
+ |> Map.put(:scheduled_at, scheduled_at)
+ end
+
+ def expiration_in_the_past_factory(attrs \\ %{}) do
+ expiration_offset_by_minutes(attrs, -60)
+ end
+
+ def expiration_in_the_future_factory(attrs \\ %{}) do
+ expiration_offset_by_minutes(attrs, 61)
+ end
+
def article_activity_factory do
article = insert(:article)
@@ -187,13 +207,15 @@ defmodule Pleroma.Factory do
object = Object.normalize(note_activity)
user = insert(:user)
- data = %{
- "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
- "actor" => user.ap_id,
- "type" => "Like",
- "object" => object.data["id"],
- "published_at" => DateTime.utc_now() |> DateTime.to_iso8601()
- }
+ data =
+ %{
+ "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
+ "actor" => user.ap_id,
+ "type" => "Like",
+ "object" => object.data["id"],
+ "published_at" => DateTime.utc_now() |> DateTime.to_iso8601()
+ }
+ |> Map.merge(attrs[:data_attrs] || %{})
%Pleroma.Activity{
data: data