X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fuser_test.exs;h=e31b88b28e19d55e4725d7f549410ec90969d2c2;hb=b5d486d9ac40c051c23d23ef5a48685d08127904;hp=b8d41ecfd8407da1a416b2ce4e230b9ef8db02aa;hpb=b531e366dfffa6b34900dd249492707bff647401;p=akkoma
diff --git a/test/user_test.exs b/test/user_test.exs
index b8d41ecfd..e31b88b28 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
@@ -199,6 +200,13 @@ defmodule Pleroma.UserTest do
refute User.following?(followed, user)
end
+ test "fetches correct profile for nickname beginning with number" do
+ # Use old-style integer ID to try to reproduce the problem
+ user = insert(:user, %{id: 1080})
+ userwithnumbers = insert(:user, %{nickname: "#{user.id}garbage"})
+ assert userwithnumbers == User.get_cached_by_nickname_or_id(userwithnumbers.nickname)
+ end
+
describe "user registration" do
@full_user_data %{
bio: "A guy",
@@ -879,7 +887,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
@@ -887,7 +899,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
@@ -929,7 +945,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
@@ -940,6 +957,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
@@ -951,13 +969,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
@@ -1053,6 +1071,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