Fixes #415. Properly handle nil and empty string by User.parse_bio
This commit is contained in:
parent
cf85a9aea1
commit
9ba4a1c5fe
@ -804,7 +804,11 @@ defmodule Pleroma.User do
|
|||||||
end
|
end
|
||||||
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)
|
mentions = Formatter.parse_mentions(bio)
|
||||||
tags = Formatter.parse_tags(bio)
|
tags = Formatter.parse_tags(bio)
|
||||||
|
|
||||||
|
@ -246,7 +246,24 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||||||
"nickname" => "lain",
|
"nickname" => "lain",
|
||||||
"email" => "lain@wired.jp",
|
"email" => "lain@wired.jp",
|
||||||
"fullname" => "lain iwakura",
|
"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",
|
"password" => "bear",
|
||||||
"confirm" => "bear"
|
"confirm" => "bear"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user