From 956f3c75ca8dec32534f432d7bde9f6235a3e7b3 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 5 Dec 2018 03:35:41 +0000 Subject: [PATCH 1/2] user: put default user info when registering a user --- lib/pleroma/user.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 3bd92c157..74ae5ef0d 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -177,6 +177,7 @@ def register_changeset(struct, params \\ %{}) do |> validate_format(:email, @email_regex) |> validate_length(:bio, max: 1000) |> validate_length(:name, min: 1, max: 100) + |> put_change(:info, %Pleroma.User.Info{}) if changeset.valid? do hashed = Pbkdf2.hashpwsalt(changeset.changes[:password]) From 0f061bea0c217de8560ca235500959a463dd17ef Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 5 Dec 2018 03:41:32 +0000 Subject: [PATCH 2/2] tests: add regression test for bug #408 --- test/user_test.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/user_test.exs b/test/user_test.exs index d097eb171..3d2f7f4e0 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -149,6 +149,18 @@ test "it sets the password_hash, ap_id and following fields" do assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers" end + + test "it ensures info is not nil" do + changeset = User.register_changeset(%User{}, @full_user_data) + + assert changeset.valid? + + {:ok, user} = + changeset + |> Repo.insert() + + refute is_nil(user.info) + end end describe "fetching a user from nickname or trying to build one" do