X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fuser_test.exs;h=8cf2ba6ab1d5251c6b71ccb783853e9d7f43564d;hb=c810fb81a489dc3faeb1f21092c89a3131188ac1;hp=0b1c39ecf82d1b83f25f488155efbcb04bb3e390;hpb=11b3c10c54254ecad4b52f27856b8d95629e541c;p=akkoma
diff --git a/test/user_test.exs b/test/user_test.exs
index 0b1c39ecf..8cf2ba6ab 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -3,11 +3,12 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.UserTest do
- alias Pleroma.Builders.UserBuilder
alias Pleroma.Activity
+ alias Pleroma.Builders.UserBuilder
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.CommonAPI
+
use Pleroma.DataCase
import Pleroma.Factory
@@ -50,6 +51,34 @@ defmodule Pleroma.UserTest do
assert expected_followers_collection == User.ap_followers(user)
end
+ test "returns all pending follow requests" do
+ unlocked = insert(:user)
+ locked = insert(:user, %{info: %{locked: true}})
+ follower = insert(:user)
+
+ Pleroma.Web.TwitterAPI.TwitterAPI.follow(follower, %{"user_id" => unlocked.id})
+ Pleroma.Web.TwitterAPI.TwitterAPI.follow(follower, %{"user_id" => locked.id})
+
+ assert {:ok, []} = User.get_follow_requests(unlocked)
+ assert {:ok, [activity]} = User.get_follow_requests(locked)
+
+ assert activity
+ end
+
+ test "doesn't return already accepted or duplicate follow requests" do
+ locked = insert(:user, %{info: %{locked: true}})
+ pending_follower = insert(:user)
+ accepted_follower = insert(:user)
+
+ Pleroma.Web.TwitterAPI.TwitterAPI.follow(pending_follower, %{"user_id" => locked.id})
+ Pleroma.Web.TwitterAPI.TwitterAPI.follow(pending_follower, %{"user_id" => locked.id})
+ Pleroma.Web.TwitterAPI.TwitterAPI.follow(accepted_follower, %{"user_id" => locked.id})
+ User.maybe_follow(accepted_follower, locked)
+
+ assert {:ok, [activity]} = User.get_follow_requests(locked)
+ assert activity
+ end
+
test "follow_all follows mutliple users" do
user = insert(:user)
followed_zero = insert(:user)
@@ -851,7 +880,11 @@ defmodule Pleroma.UserTest do
user = insert(:user, %{nickname: "john"})
Enum.each(["john", "jo", "j"], fn query ->
- assert user == User.search(query) |> List.first() |> Map.put(:search_rank, nil)
+ assert user ==
+ User.search(query)
+ |> List.first()
+ |> Map.put(:search_rank, nil)
+ |> Map.put(:search_type, nil)
end)
end
@@ -859,7 +892,11 @@ defmodule Pleroma.UserTest do
user = insert(:user, %{name: "John Doe"})
Enum.each(["John Doe", "JOHN", "doe", "j d", "j", "d"], fn query ->
- assert user == User.search(query) |> List.first() |> Map.put(:search_rank, nil)
+ assert user ==
+ User.search(query)
+ |> List.first()
+ |> Map.put(:search_rank, nil)
+ |> Map.put(:search_type, nil)
end)
end
@@ -901,7 +938,8 @@ defmodule Pleroma.UserTest do
{:ok, follower} = User.follow(follower, u1)
{:ok, u1} = User.follow(u1, friend)
- assert [friend.id, follower.id, u2.id] == Enum.map(User.search("doe", false, u1), & &1.id)
+ assert [friend.id, follower.id, u2.id] --
+ Enum.map(User.search("doe", resolve: false, for_user: u1), & &1.id) == []
end
test "finds a user whose name is nil" do
@@ -912,6 +950,7 @@ defmodule Pleroma.UserTest do
User.search("lain@pleroma.soykaf.com")
|> List.first()
|> Map.put(:search_rank, nil)
+ |> Map.put(:search_type, nil)
end
test "does not yield false-positive matches" do
@@ -923,13 +962,13 @@ defmodule Pleroma.UserTest do
end
test "works with URIs" do
- results = User.search("http://mastodon.example.org/users/admin", true)
+ results = User.search("http://mastodon.example.org/users/admin", resolve: true)
result = results |> List.first()
user = User.get_by_ap_id("http://mastodon.example.org/users/admin")
assert length(results) == 1
- assert user == result |> Map.put(:search_rank, nil)
+ assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
end
end
@@ -1025,6 +1064,22 @@ defmodule Pleroma.UserTest do
assert expected_text == User.parse_bio(bio, user)
end
+
+ test "Adds rel=me on linkbacked urls" do
+ user = insert(:user, ap_id: "http://social.example.org/users/lain")
+
+ bio = "http://example.org/rel_me/null"
+ expected_text = "#{bio}"
+ assert expected_text == User.parse_bio(bio, user)
+
+ bio = "http://example.org/rel_me/link"
+ expected_text = "#{bio}"
+ assert expected_text == User.parse_bio(bio, user)
+
+ bio = "http://example.org/rel_me/anchor"
+ expected_text = "#{bio}"
+ assert expected_text == User.parse_bio(bio, user)
+ end
end
test "bookmarks" do