Skip to content

Commit

Permalink
chore: update tests to reflect simpler form value behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 28, 2024
1 parent c270d64 commit 86a682b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/ash_phoenix/form/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2787,10 +2787,14 @@ defmodule AshPhoenix.Form do
get_data_value(value, field)
end

defp get_data_value(%Ash.Union{value: value}, field) do
defp get_data_value(%Ash.Union{value: value}, field) when is_struct(value) do
get_data_value(value, field)
end

defp get_data_value(%Ash.Union{value: value}, :value) do
{:ok, value}
end

defp get_data_value(value, field) when is_map(value) do
Map.fetch(value, field)
end
Expand Down
8 changes: 3 additions & 5 deletions test/auto_form_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,7 @@ defmodule AshPhoenix.AutoFormTest do
)
|> Phoenix.HTML.FormData.to_form([])

assert Enum.at(form[:union].value, 0)[:value].value == %Ash.Union{
value: :update,
type: :predefined
}
assert Enum.at(form[:union].value, 0)[:value].value == :update
end
end

Expand All @@ -368,7 +365,8 @@ defmodule AshPhoenix.AutoFormTest do
|> form_for("action")
end

test "show correct values on for_update forms" do
test "
show correct values on for_update forms" do
a =
Post
|> AshPhoenix.Form.for_create(:create, domain: Domain, forms: [auto?: true])
Expand Down

0 comments on commit 86a682b

Please sign in to comment.