forked from AkkomaGang/akkoma
Update test for get_recipients_from_activity
This commit is contained in:
parent
363e76d4da
commit
d1ae51b02a
1 changed files with 41 additions and 18 deletions
|
@ -878,27 +878,50 @@ test "it imports user blocks from list" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "get recipients from activity" do
|
describe "get_recipients_from_activity" do
|
||||||
actor = insert(:user)
|
test "get recipients" do
|
||||||
user = insert(:user, local: true)
|
actor = insert(:user)
|
||||||
user_two = insert(:user, local: false)
|
user = insert(:user, local: true)
|
||||||
addressed = insert(:user, local: true)
|
user_two = insert(:user, local: false)
|
||||||
addressed_remote = insert(:user, local: false)
|
addressed = insert(:user, local: true)
|
||||||
|
addressed_remote = insert(:user, local: false)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
CommonAPI.post(actor, %{
|
CommonAPI.post(actor, %{
|
||||||
"status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}"
|
"status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}"
|
||||||
})
|
})
|
||||||
|
|
||||||
assert Enum.map([actor, addressed], & &1.ap_id) --
|
assert Enum.map([actor, addressed], & &1.ap_id) --
|
||||||
Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == []
|
Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == []
|
||||||
|
|
||||||
{:ok, user} = User.follow(user, actor)
|
{:ok, user} = User.follow(user, actor)
|
||||||
{:ok, _user_two} = User.follow(user_two, actor)
|
{:ok, _user_two} = User.follow(user_two, actor)
|
||||||
recipients = User.get_recipients_from_activity(activity)
|
recipients = User.get_recipients_from_activity(activity)
|
||||||
assert length(recipients) == 3
|
assert length(recipients) == 3
|
||||||
assert user in recipients
|
assert user in recipients
|
||||||
assert addressed in recipients
|
assert addressed in recipients
|
||||||
|
end
|
||||||
|
|
||||||
|
test "has following" do
|
||||||
|
actor = insert(:user)
|
||||||
|
user = insert(:user)
|
||||||
|
user_two = insert(:user)
|
||||||
|
addressed = insert(:user, local: true)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(actor, %{
|
||||||
|
"status" => "hey @#{addressed.nickname}"
|
||||||
|
})
|
||||||
|
|
||||||
|
assert Enum.map([actor, addressed], & &1.ap_id) --
|
||||||
|
Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == []
|
||||||
|
|
||||||
|
{:ok, _actor} = User.follow(actor, user)
|
||||||
|
{:ok, _actor} = User.follow(actor, user_two)
|
||||||
|
recipients = User.get_recipients_from_activity(activity)
|
||||||
|
assert length(recipients) == 2
|
||||||
|
assert addressed in recipients
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".deactivate" do
|
describe ".deactivate" do
|
||||||
|
|
Loading…
Reference in a new issue