def update_profile(%{assigns: %{user: user}} = conn, params) do
params =
if bio = params["description"] do
- bio_brs = Regex.replace(~r/\r?\n/,bio,"<br>")
+ bio_brs = Regex.replace(~r/\r?\n/, bio, "<br>")
Map.put(params, "bio", bio_brs)
else
params
end
test "Convert newlines to <br> in bio", %{conn: conn} do
- user = insert(:user)
+ user = insert(:user)
- conn =
- conn
- |> assign(:user, user)
- |> post("/api/account/update_profile.json", %{
- "description" => "Hello,\r\nWorld! I\n am a test."
- })
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/account/update_profile.json", %{
+ "description" => "Hello,\r\nWorld! I\n am a test."
+ })
- user = Repo.get!(User, user.id)
- assert user.bio == "Hello,<br>World! I<br> am a test."
+ user = Repo.get!(User, user.id)
+ assert user.bio == "Hello,<br>World! I<br> am a test."
end
-
-
end