Introduce avatar and banner and fetch Gravatar to fill avatar during registration

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

typo

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Rename avatar to avatar_url, same with header.

Add a comment to explain why the tweak with HTTPoison and TLS1.2

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Rename avatar to avatar_url

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

rename old avatar properties in front-end to avatar_url

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

fix change gravatar from ?d= to ?default=

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

reorganize aliases and imports

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

set avatar url only when gravatar exists, add a test for that case

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-01-26 11:02:11 +01:00
parent 35492570de
commit 4b4ecec693
11 changed files with 71 additions and 23 deletions

View File

@@ -32,14 +32,23 @@ defmodule EventosWeb.UserControllerTest do
describe "create user" do
test "renders user when data is valid", %{conn: conn} do
conn = post conn, user_path(conn, :create), @create_attrs
assert %{"user" => %{"id" => id}} = json_response(conn, 201)
assert %{"user" => %{"id" => id, "account" => %{"avatar_url" => avatar_url}}} = json_response(conn, 201)
assert id > 0
assert avatar_url == nil
end
test "renders errors when data is invalid", %{conn: conn} do
conn = post conn, user_path(conn, :create), @invalid_attrs
assert json_response(conn, 400)["msg"] != %{}
end
test "renders user with avatar when email is valid", %{conn: conn} do
attrs = %{email: "contact@framasoft.org", password: "some password_hash", username: "framasoft"}
conn = post conn, user_path(conn, :create), attrs
assert %{"user" => %{"id" => id, "account" => %{"avatar_url" => avatar_url}}} = json_response(conn, 201)
assert id > 0
assert avatar_url == "https://secure.gravatar.com/avatar/68b2910a6bb84a482d920e1057533100?default=404"
end
end
# describe "update user" do