Fix user information to include payload returned from identity provider (#2890)

This commit is contained in:
Hugo Baraúna 2024-12-06 10:36:52 -03:00 committed by GitHub
parent dba7cbf7be
commit 2d9b6f8dac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -42,13 +42,14 @@ defmodule Livebook.Users.User do
name: nil,
email: nil,
avatar_url: nil,
payload: nil,
hex_color: Livebook.EctoTypes.HexColor.random()
}
end
def changeset(user, attrs \\ %{}) do
user
|> cast(attrs, [:name, :email, :avatar_url, :hex_color])
|> cast(attrs, [:name, :email, :avatar_url, :hex_color, :payload])
|> validate_required([:hex_color])
end
end

View file

@ -6,12 +6,19 @@ defmodule Livebook.Users.UserTest do
describe "change/2" do
test "given valid attributes returns and updated user" do
user = build(:user)
attrs = %{"name" => "Jake Peralta", "hex_color" => "#000000"}
attrs = %{
"name" => "Jake Peralta",
"hex_color" => "#000000",
"payload" => %{"country" => "US"}
}
changeset = User.changeset(user, attrs)
assert changeset.valid?
assert get_field(changeset, :name) == "Jake Peralta"
assert get_field(changeset, :hex_color) == "#000000"
assert get_field(changeset, :payload) == %{"country" => "US"}
end
test "given invalid color returns an error" do