aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkaniini <nenolod@gmail.com>2019-02-18 04:01:26 +0000
committerkaniini <nenolod@gmail.com>2019-02-18 04:01:26 +0000
commitcd019a5927059bb52447add43a9b29893928c416 (patch)
treef9a78a61375bb9074664dd9e9925c797ce05b732 /test
parent3f38a055715a8140524f4f55073d5b936d076fb4 (diff)
parentecdf0657ba4a90d821d3874c827593963e0ff041 (diff)
downloadpleroma-cd019a5927059bb52447add43a9b29893928c416.tar.gz
Merge branch 'follow-request-count' into 'develop'
Follow request count See merge request pleroma/pleroma!817
Diffstat (limited to 'test')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs8
-rw-r--r--test/web/twitter_api/twitter_api_controller_test.exs26
2 files changed, 33 insertions, 1 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index 26c9c25a6..7749c5ded 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -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
diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs
index f7e40e0d3..d6b1331bd 100644
--- a/test/web/twitter_api/twitter_api_controller_test.exs
+++ b/test/web/twitter_api/twitter_api_controller_test.exs
@@ -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