diff options
author | kaniini <ariadne@dereferenced.org> | 2019-08-24 16:01:57 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-08-24 16:01:57 +0000 |
commit | 83aeb6090072986d39dc52de05f5a23164f8ce04 (patch) | |
tree | 1f510711f7bad7b69df9d3c2d01f3663d4e126fb /test/support | |
parent | bc78a875c86db42d67122cfb767f239a55dacbea (diff) | |
parent | 1d7033d96289edf0adf2ca61a725f93b345305ec (diff) | |
download | pleroma-83aeb6090072986d39dc52de05f5a23164f8ce04.tar.gz |
Merge branch 'activity-expiration' into 'develop'
Activity expiration
See merge request pleroma/pleroma!1595
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/factory.ex | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index 1787c1088..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 <https://pleroma.social/> +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> # 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) |