Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
e8d8c84f
Commit
e8d8c84f
authored
Nov 16, 2018
by
lain
Browse files
Add better test for user search functionlity.
parent
27aa136a
Pipeline
#4501
passed with stages
in 6 minutes and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
e8d8c84f
...
...
@@ -498,7 +498,7 @@ def get_recipients_from_activity(%Activity{recipients: to}) do
Repo
.
all
(
query
)
end
def
search
(
query
,
resolve
)
do
def
search
(
query
,
resolve
\\
false
)
do
# strip the beginning @ off if there is a query
query
=
String
.
trim_leading
(
query
,
"@"
)
...
...
test/user_test.exs
View file @
e8d8c84f
...
...
@@ -578,4 +578,16 @@ test "User.delete() plugs any possible zombie objects" do
assert
cached_user
!=
user
end
end
describe
"User.search"
do
test
"finds a user, ranking by similarity"
do
user
=
insert
(
:user
,
%{
name:
"lain"
})
user_two
=
insert
(
:user
,
%{
name:
"ean"
})
user_three
=
insert
(
:user
,
%{
name:
"ebn"
,
nickname:
"lain@mastodon.social"
})
user_four
=
insert
(
:user
,
%{
nickname:
"lain@pleroma.soykaf.com"
})
assert
user_four
==
User
.
search
(
"lain@ple"
)
|>
List
.
first
()
|>
Map
.
put
(
:search_distance
,
nil
)
end
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment