X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fsupport%2Ffactory.ex;h=62d1de717c924c414a9ce06c4ec5f26ce615d86e;hb=503139b3431799fed3f280d990fb26c6632f2f25;hp=9ef1b789c97b504a14b1a5e69f9c531d62daa8b1;hpb=9d4f34fbcb1a8e2eca424b3a3374c9f9af972574;p=akkoma
diff --git a/test/support/factory.ex b/test/support/factory.ex
index 9ef1b789c..62d1de717 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
@@ -143,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)
@@ -183,8 +202,8 @@ defmodule Pleroma.Factory do
}
end
- def like_activity_factory do
- note_activity = insert(:note_activity)
+ def like_activity_factory(attrs \\ %{}) do
+ note_activity = attrs[:note_activity] || insert(:note_activity)
object = Object.normalize(note_activity)
user = insert(:user)