summaryrefslogtreecommitdiff
path: root/test/web/activity_pub/visibilty_test.exs
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-06-05 12:54:30 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-06-05 12:54:30 +0700
commit6ba9055b51a454baaf063943e72a39006f7e5fad (patch)
treeca54523b21a7fe5a5ef0c99b2032fc0f899d40a8 /test/web/activity_pub/visibilty_test.exs
parent9ce928d8238877f870e099cb2fe010d322717856 (diff)
parent5188add534a1532ef323a0fec3503f8e96dfe762 (diff)
downloadpleroma-6ba9055b51a454baaf063943e72a39006f7e5fad.tar.gz
pleroma-6ba9055b51a454baaf063943e72a39006f7e5fad.zip
Merge remote-tracking branch 'pleroma/develop' into feature/addressable-lists
Diffstat (limited to 'test/web/activity_pub/visibilty_test.exs')
-rw-r--r--test/web/activity_pub/visibilty_test.exs43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/web/activity_pub/visibilty_test.exs b/test/web/activity_pub/visibilty_test.exs
index 466d980dc..e24df3cab 100644
--- a/test/web/activity_pub/visibilty_test.exs
+++ b/test/web/activity_pub/visibilty_test.exs
@@ -1,6 +1,7 @@
defmodule Pleroma.Web.ActivityPub.VisibilityTest do
use Pleroma.DataCase
+ alias Pleroma.Activity
alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
@@ -121,4 +122,46 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
test "get_visibility with directMessage flag" do
assert Visibility.get_visibility(%{data: %{"directMessage" => true}}) == "direct"
end
+
+ describe "entire_thread_visible_for_user?/2" do
+ test "returns false if not found activity", %{user: user} do
+ refute Visibility.entire_thread_visible_for_user?(%Activity{}, user)
+ end
+
+ test "returns true if activity hasn't 'Create' type", %{user: user} do
+ activity = insert(:like_activity)
+ assert Visibility.entire_thread_visible_for_user?(activity, user)
+ end
+
+ test "returns false when invalid recipients", %{user: user} do
+ author = insert(:user)
+
+ activity =
+ insert(:note_activity,
+ note:
+ insert(:note,
+ user: author,
+ data: %{"to" => ["test-user"]}
+ )
+ )
+
+ refute Visibility.entire_thread_visible_for_user?(activity, user)
+ end
+
+ test "returns true if user following to author" do
+ author = insert(:user)
+ user = insert(:user, following: [author.ap_id])
+
+ activity =
+ insert(:note_activity,
+ note:
+ insert(:note,
+ user: author,
+ data: %{"to" => [user.ap_id]}
+ )
+ )
+
+ assert Visibility.entire_thread_visible_for_user?(activity, user)
+ end
+ end
end