fix(export): emit date custom-field values as ISO-8601 for re-import

This commit is contained in:
Moritz 2026-06-03 01:54:49 +02:00
parent d51dcb1ac3
commit 5c5fd56749
2 changed files with 35 additions and 4 deletions

View file

@ -0,0 +1,27 @@
defmodule Mv.Membership.CustomFieldValueFormatterTest do
use ExUnit.Case, async: true
alias Mv.Membership.CustomFieldValueFormatter
describe "format_custom_field_value/2 for :date" do
test "formats an Ash.Union date value as ISO-8601" do
union = %Ash.Union{value: ~D[2024-03-15], type: :date}
assert CustomFieldValueFormatter.format_custom_field_value(union, %{value_type: :date}) ==
"2024-03-15"
end
test "formats a direct Date value as ISO-8601" do
assert CustomFieldValueFormatter.format_custom_field_value(~D[2024-03-15], %{
value_type: :date
}) == "2024-03-15"
end
test "formats an already-stored ISO-8601 string date as ISO-8601" do
union = %Ash.Union{value: "2024-03-15", type: :date}
assert CustomFieldValueFormatter.format_custom_field_value(union, %{value_type: :date}) ==
"2024-03-15"
end
end
end