Skip to content

Commit

Permalink
Fix user information to include payload returned from identity provid…
Browse files Browse the repository at this point in the history
…er (#2890)
  • Loading branch information
hugobarauna authored Dec 6, 2024
1 parent dba7cbf commit 2d9b6f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/livebook/users/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion test/livebook/users/user_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d9b6f8

Please sign in to comment.