Skip to content
GitLab
Menu
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
9ba4a1c5
Commit
9ba4a1c5
authored
Dec 10, 2018
by
raeno
Browse files
Fixes
#415
. Properly handle nil and empty string by User.parse_bio
parent
cf85a9ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
9ba4a1c5
...
...
@@ -804,7 +804,11 @@ def wait_and_refresh(timeout, %User{} = a, %User{} = b) do
end
end
def
parse_bio
(
bio
,
user
\\
%
User
{
info:
%{
source_data:
%{}}})
do
def
parse_bio
(
bio
,
user
\\
%
User
{
info:
%{
source_data:
%{}}})
def
parse_bio
(
nil
,
user
),
do
:
""
def
parse_bio
(
bio
,
user
)
when
bio
==
""
,
do
:
bio
def
parse_bio
(
bio
,
user
)
do
mentions
=
Formatter
.
parse_mentions
(
bio
)
tags
=
Formatter
.
parse_tags
(
bio
)
...
...
test/web/twitter_api/twitter_api_test.exs
View file @
9ba4a1c5
...
...
@@ -246,7 +246,24 @@ test "it registers a new user and returns the user." do
"nickname"
=>
"lain"
,
"email"
=>
"lain@wired.jp"
,
"fullname"
=>
"lain iwakura"
,
"bio"
=>
"close the world."
,
"password"
=>
"bear"
,
"confirm"
=>
"bear"
}
{
:ok
,
user
}
=
TwitterAPI
.
register_user
(
data
)
fetched_user
=
Repo
.
get_by
(
User
,
nickname:
"lain"
)
assert
UserView
.
render
(
"show.json"
,
%{
user:
user
})
==
UserView
.
render
(
"show.json"
,
%{
user:
fetched_user
})
end
test
"it registers a new user with empty string in bio and returns the user."
do
data
=
%{
"nickname"
=>
"lain"
,
"email"
=>
"lain@wired.jp"
,
"fullname"
=>
"lain iwakura"
,
"bio"
=>
""
,
"password"
=>
"bear"
,
"confirm"
=>
"bear"
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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