Skip to content

Commit f4843b6

Browse files
committed
Add failing test for polymorphic_embed_inputs_for child errors with nil parent action
1 parent b74f402 commit f4843b6

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/polymorphic_embed_test.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,6 +2857,30 @@ defmodule PolymorphicEmbedTest do
28572857
end
28582858
end
28592859

2860+
test "polymorphic_embed_inputs_for ignores child errors when parent action is nil" do
2861+
reminder_module = get_module(Reminder, :polymorphic)
2862+
2863+
attrs = %{
2864+
date: ~U[2020-05-28 02:57:19Z],
2865+
text: "This is an Email reminder",
2866+
channel: %{
2867+
address: "a",
2868+
valid: true,
2869+
confirmed: true
2870+
}
2871+
}
2872+
2873+
changeset =
2874+
struct(reminder_module)
2875+
|> reminder_module.changeset(attrs)
2876+
2877+
safe_inputs_for(changeset, :channel, :polymorphic, fn f ->
2878+
assert f.impl == Phoenix.HTML.FormData.Ecto.Changeset
2879+
assert f.errors == []
2880+
text_input(f, :address)
2881+
end)
2882+
end
2883+
28602884
test "polymorphic_embed_inputs_for/4 for list of embeds" do
28612885
for generator <- @generators do
28622886
reminder_module = get_module(Reminder, generator)

0 commit comments

Comments
 (0)