summaryrefslogtreecommitdiff
path: root/test/conversation
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2019-12-19 12:16:33 -0600
committerMark Felder <feld@FreeBSD.org>2019-12-19 12:16:33 -0600
commit50638525db6bf7d59c4a5820848c9f6773cc49e1 (patch)
tree6d94f34ddd482d57178107076a7e2f44698a3e43 /test/conversation
parentdf469b4468168cf072e73df73e0fdde2bbab1da5 (diff)
parent38ad407395e838ddf1c11922806adc080af44d36 (diff)
downloadpleroma-50638525db6bf7d59c4a5820848c9f6773cc49e1.tar.gz
pleroma-50638525db6bf7d59c4a5820848c9f6773cc49e1.zip
Merge branch 'develop' into config/benchmark
Diffstat (limited to 'test/conversation')
-rw-r--r--test/conversation/participation_test.exs17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs
index 9b2c97963..ba81c0d4b 100644
--- a/test/conversation/participation_test.exs
+++ b/test/conversation/participation_test.exs
@@ -5,7 +5,9 @@
defmodule Pleroma.Conversation.ParticipationTest do
use Pleroma.DataCase
import Pleroma.Factory
+ alias Pleroma.Conversation
alias Pleroma.Conversation.Participation
+ alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.CommonAPI
@@ -98,7 +100,9 @@ defmodule Pleroma.Conversation.ParticipationTest do
assert participation.user_id == user.id
assert participation.conversation_id == conversation.id
+ # Needed because updated_at is accurate down to a second
:timer.sleep(1000)
+
# Creating again returns the same participation
{:ok, %Participation{} = participation_two} =
Participation.create_for_user_and_conversation(user, conversation)
@@ -150,9 +154,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
test "gets all the participations for a user, ordered by updated at descending" do
user = insert(:user)
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
- :timer.sleep(1000)
{:ok, activity_two} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
- :timer.sleep(1000)
{:ok, activity_three} =
CommonAPI.post(user, %{
@@ -161,6 +163,17 @@ defmodule Pleroma.Conversation.ParticipationTest do
"in_reply_to_status_id" => activity_one.id
})
+ # Offset participations because the accuracy of updated_at is down to a second
+
+ for {activity, offset} <- [{activity_two, 1}, {activity_three, 2}] do
+ conversation = Conversation.get_for_ap_id(activity.data["context"])
+ participation = Participation.for_user_and_conversation(user, conversation)
+ updated_at = NaiveDateTime.add(Map.get(participation, :updated_at), offset)
+
+ Ecto.Changeset.change(participation, %{updated_at: updated_at})
+ |> Repo.update!()
+ end
+
assert [participation_one, participation_two] = Participation.for_user(user)
object2 = Pleroma.Object.normalize(activity_two)