X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fpush%2Fimpl_test.exs;h=2f6ce4bd206c862865c006f631ea886eb16e7884;hb=a15b9cbef1b8b06f4fdbfb224f783ea78d1ce27a;hp=49b2a92030b59791ec337f58d5b56cd152bfe535;hpb=e8c2f9a73a37636a9a8ed5c2998617b841f482da;p=akkoma
diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs
index 49b2a9203..2f6ce4bd2 100644
--- a/test/web/push/impl_test.exs
+++ b/test/web/push/impl_test.exs
@@ -1,10 +1,12 @@
# 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.Web.Push.ImplTest do
use Pleroma.DataCase
+ alias Pleroma.Object
+ alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Push.Impl
alias Pleroma.Web.Push.Subscription
@@ -52,16 +54,12 @@ defmodule Pleroma.Web.Push.ImplTest do
data: %{alerts: %{"follow" => true, "mention" => false}}
)
+ {:ok, activity} = CommonAPI.post(user, %{"status" => " "Create",
- "actor" => user.ap_id,
- "object" => %{"content" => "
+ "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
+ })
+
+ object = Object.normalize(activity)
+
assert Impl.format_body(
%{
- activity: %{
- data: %{
- "type" => "Create",
- "object" => %{
- "content" =>
- "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
- }
- }
- }
+ activity: activity
},
- %{nickname: "Bob"}
+ user,
+ object
) ==
"@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
end
test "renders body for follow activity" do
- assert Impl.format_body(%{activity: %{data: %{"type" => "Follow"}}}, %{nickname: "Bob"}) ==
- "@Bob has followed you"
+ user = insert(:user, nickname: "Bob")
+ other_user = insert(:user)
+ {:ok, _, _, activity} = CommonAPI.follow(user, other_user)
+ object = Object.normalize(activity)
+
+ assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has followed you"
end
test "renders body for announce activity" do
user = insert(:user)
- note =
- insert(:note, %{
- data: %{
- "content" =>
- "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
- }
+ {:ok, activity} =
+ CommonAPI.post(user, %{
+ "status" =>
+ "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
- note_activity = insert(:note_activity, %{note: note})
- announce_activity = insert(:announce_activity, %{user: user, note_activity: note_activity})
+ {:ok, announce_activity, _} = CommonAPI.repeat(activity.id, user)
+ object = Object.normalize(activity)
- assert Impl.format_body(%{activity: announce_activity}, user) ==
+ assert Impl.format_body(%{activity: announce_activity}, user, object) ==
"@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
end
test "renders body for like activity" do
- assert Impl.format_body(%{activity: %{data: %{"type" => "Like"}}}, %{nickname: "Bob"}) ==
- "@Bob has favorited your post"
+ user = insert(:user, nickname: "Bob")
+
+ {:ok, activity} =
+ CommonAPI.post(user, %{
+ "status" =>
+ "Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
+ })
+
+ {:ok, activity, _} = CommonAPI.favorite(activity.id, user)
+ object = Object.normalize(activity)
+
+ assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has favorited your post"
end
end