Fix ObjectTest
This commit is contained in:
parent
0524e66a05
commit
505e58d4eb
1 changed files with 5 additions and 3 deletions
|
@ -100,12 +100,14 @@ defmodule Pleroma.Object.Updater do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_update_poll(to_be_updated, updated_object) do
|
defp maybe_update_poll(to_be_updated, updated_object) do
|
||||||
choice_key = fn data ->
|
choice_key = fn
|
||||||
if Map.has_key?(data, "anyOf"), do: "anyOf", else: "oneOf"
|
%{"anyOf" => [_ | _]} = data -> "anyOf"
|
||||||
|
%{"oneOf" => [_ | _]} = data -> "oneOf"
|
||||||
|
_ -> nil
|
||||||
end
|
end
|
||||||
|
|
||||||
with true <- to_be_updated["type"] == "Question",
|
with true <- to_be_updated["type"] == "Question",
|
||||||
key <- choice_key.(updated_object),
|
key when not is_nil(key) <- choice_key.(updated_object),
|
||||||
true <- key == choice_key.(to_be_updated),
|
true <- key == choice_key.(to_be_updated),
|
||||||
orig_choices <- to_be_updated[key] |> Enum.map(&Map.drop(&1, ["replies"])),
|
orig_choices <- to_be_updated[key] |> Enum.map(&Map.drop(&1, ["replies"])),
|
||||||
new_choices <- updated_object[key] |> Enum.map(&Map.drop(&1, ["replies"])),
|
new_choices <- updated_object[key] |> Enum.map(&Map.drop(&1, ["replies"])),
|
||||||
|
|
Loading…
Reference in a new issue