Hi all
I try to adapt a generated liew view to my needs and I get a failing test, I cannot make sense of.
If have this schema:
schema "accounts" do
field :currency, Ecto.Enum, values: [:chf, :eur]
field :name, :string
field :retired, :boolean, default: false
timestamps()
end
In the edit form I use a radio button for the currency field:
<%= for currency_option <- @currency_options do %>
<p>
<%= radio_button f, :currency, currency_option[:value] %>
<%= label f, :currency, currency_option[:key],
for: input_id(f, :currency, currency_option[:value]) %>
</p>
<% end %>
In the test, the form is first submitted with invalid data (currency: nil) and the error messages are checked:
assert index_live
|> form("#account-form", account: @invalid_attrs)
|> render_change() =~ "can't be blank"
Unfortunately, the does throws the following error:
** (ArgumentError) value for radio "account[currency]" must be one of ["chf", "eur"], got: ""
code: |> render_change() =~ "can't be blank"
Kind regards
Daniel