chore: fix tests

This commit is contained in:
Zach Daniel 2022-05-28 21:20:54 -04:00
parent d80a87c062
commit 09f673751b
3 changed files with 10 additions and 6 deletions

View file

@ -352,6 +352,7 @@ defmodule AshPhoenix.Form.Auto do
Keyword.update!(opts, :forms, fn forms ->
Keyword.put(forms, :_join,
resource: relationship.through,
type: :single,
managed_relationship: {relationship.source, relationship.name},
create_action: action.name
)

View file

@ -1865,11 +1865,11 @@ defmodule AshPhoenix.Form do
touched_forms = opts[:touched_forms] || MapSet.new()
touched_forms =
Enum.reduce(forms, touched_forms, fn {key, form_or_forms}, touched_forms ->
if form_or_forms in [nil, []] do
touched_forms
else
Enum.reduce(forms, touched_forms, fn {key, _form_or_forms}, touched_forms ->
if Map.has_key?(params, to_string(key)) do
MapSet.put(touched_forms, to_string(key))
else
touched_forms
end
end)
@ -2945,6 +2945,9 @@ defmodule AshPhoenix.Form do
as: name <> "[#{key}]",
id: id <> "_#{key}"
)
other ->
raise "unexpected form type for form with no data #{other} with params: #{inspect(form_params)}"
end
end
else

View file

@ -922,7 +922,7 @@ defmodule AshPhoenix.FormTest do
form =
comment
|> Form.for_update(:create,
|> Form.for_update(:update,
forms: [
post: [
data: comment.post,
@ -1006,7 +1006,7 @@ defmodule AshPhoenix.FormTest do
form =
comment
|> Form.for_update(:create,
|> Form.for_update(:update,
forms: [
posts: [
data: comment.post,