mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-26 16:02:18 +00:00
CommonAPI: Add test for accept_follow_request.
This commit is contained in:
parent
076c9ae40e
commit
827a51e777
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import Pleroma.Factory
|
||||
|
@ -339,4 +340,46 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert User.showing_reblogs?(muter, muted) == true
|
||||
end
|
||||
end
|
||||
|
||||
describe "accept_follow_request/2" do
|
||||
test "after acceptance, it sets all existing pending follow request states to 'accept'" do
|
||||
user = insert(:user, info: %{locked: true})
|
||||
follower = insert(:user)
|
||||
follower_two = insert(:user)
|
||||
|
||||
{:ok, follow_activity} = ActivityPub.follow(follower, user)
|
||||
{:ok, follow_activity_two} = ActivityPub.follow(follower, user)
|
||||
{:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
|
||||
|
||||
assert follow_activity.data["state"] == "pending"
|
||||
assert follow_activity_two.data["state"] == "pending"
|
||||
assert follow_activity_three.data["state"] == "pending"
|
||||
|
||||
{:ok, _follower} = CommonAPI.accept_follow_request(follower, user)
|
||||
|
||||
assert Repo.get(Activity, follow_activity.id).data["state"] == "accept"
|
||||
assert Repo.get(Activity, follow_activity_two.id).data["state"] == "accept"
|
||||
assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
|
||||
end
|
||||
|
||||
test "after rejection, it sets all existing pending follow request states to 'reject'" do
|
||||
user = insert(:user, info: %{locked: true})
|
||||
follower = insert(:user)
|
||||
follower_two = insert(:user)
|
||||
|
||||
{:ok, follow_activity} = ActivityPub.follow(follower, user)
|
||||
{:ok, follow_activity_two} = ActivityPub.follow(follower, user)
|
||||
{:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
|
||||
|
||||
assert follow_activity.data["state"] == "pending"
|
||||
assert follow_activity_two.data["state"] == "pending"
|
||||
assert follow_activity_three.data["state"] == "pending"
|
||||
|
||||
{:ok, _follower} = CommonAPI.reject_follow_request(follower, user)
|
||||
|
||||
assert Repo.get(Activity, follow_activity.id).data["state"] == "reject"
|
||||
assert Repo.get(Activity, follow_activity_two.id).data["state"] == "reject"
|
||||
assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue