From 09f673751b0c5822fe97fc1a08a80382a3250b3a Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Sat, 28 May 2022 21:20:54 -0400 Subject: [PATCH] chore: fix tests --- lib/ash_phoenix/form/auto.ex | 1 + lib/ash_phoenix/form/form.ex | 11 +++++++---- test/form_test.exs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ash_phoenix/form/auto.ex b/lib/ash_phoenix/form/auto.ex index a51d214..080794b 100644 --- a/lib/ash_phoenix/form/auto.ex +++ b/lib/ash_phoenix/form/auto.ex @@ -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 ) diff --git a/lib/ash_phoenix/form/form.ex b/lib/ash_phoenix/form/form.ex index 1fc7663..9075455 100644 --- a/lib/ash_phoenix/form/form.ex +++ b/lib/ash_phoenix/form/form.ex @@ -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 diff --git a/test/form_test.exs b/test/form_test.exs index 20ff945..c54fb9a 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -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,