Commit 0863ec27 authored by lain's avatar lain
Browse files

Merge branch 'fix_empty_bio_crash' into 'develop'

Fixes #415. Do not crash during registration when hasn't filled bio field

Closes #415

See merge request !529
parents 8aa646ca 9ba4a1c5
Pipeline #5177 passed with stages
in 2 minutes and 24 seconds
......@@ -806,7 +806,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)
......
......@@ -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"
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment