Merge branch 'follow-request-count' into 'develop'
Follow request count See merge request pleroma/pleroma!817
This commit is contained in:
commit
cd019a5927
9 changed files with 91 additions and 18 deletions
|
|
@ -937,7 +937,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
end
|
||||
|
||||
test "/api/v1/follow_requests/:id/authorize works" do
|
||||
user = insert(:user, %{info: %Pleroma.User.Info{locked: true}})
|
||||
user = insert(:user, %{info: %User.Info{locked: true}})
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
|
@ -946,6 +946,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
other_user = Repo.get(User, other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
assert user.info.follow_request_count == 1
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -959,6 +960,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
other_user = Repo.get(User, other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == true
|
||||
assert user.info.follow_request_count == 0
|
||||
end
|
||||
|
||||
test "verify_credentials", %{conn: conn} do
|
||||
|
|
@ -979,6 +981,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
assert user.info.follow_request_count == 1
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|
|
@ -991,6 +996,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
other_user = Repo.get(User, other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
assert user.info.follow_request_count == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -640,6 +640,24 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
assert json_response(conn, 200) ==
|
||||
UserView.render("show.json", %{user: followed, for: current_user})
|
||||
end
|
||||
|
||||
test "for restricted account", %{conn: conn, user: current_user} do
|
||||
followed = insert(:user, info: %User.Info{locked: true})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/create.json", %{user_id: followed.id})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
followed = Repo.get(User, followed.id)
|
||||
|
||||
refute User.ap_followers(followed) in current_user.following
|
||||
assert followed.info.follow_request_count == 1
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
UserView.render("show.json", %{user: followed, for: current_user})
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /friendships/destroy.json" do
|
||||
|
|
@ -1684,15 +1702,19 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
other_user = Repo.get(User, other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
assert user.info.follow_request_count == 1
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/friendships/approve", %{"user_id" => other_user.id})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
|
||||
assert relationship = json_response(conn, 200)
|
||||
assert other_user.id == relationship["id"]
|
||||
assert relationship["follows_you"] == true
|
||||
assert user.info.follow_request_count == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1707,15 +1729,19 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
other_user = Repo.get(User, other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
assert user.info.follow_request_count == 1
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/friendships/deny", %{"user_id" => other_user.id})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
|
||||
assert relationship = json_response(conn, 200)
|
||||
assert other_user.id == relationship["id"]
|
||||
assert relationship["follows_you"] == false
|
||||
assert user.info.follow_request_count == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue