Remove unused helper function

This commit is contained in:
Uku Taht 2020-01-29 11:33:10 +02:00
parent 58eae6cd4d
commit 614e2eeb34

View File

@ -33,20 +33,4 @@ defmodule Plausible.DataCase do
:ok
end
@doc """
A helper that transforms changeset errors into a map of messages.
assert {:error, changeset} = Accounts.create_user(%{password: "short"})
assert "password is too short" in errors_on(changeset).password
assert %{password: ["password is too short"]} = errors_on(changeset)
"""
def errors_on(changeset) do
Ecto.Changeset.traverse_errors(changeset, fn {message, opts} ->
Enum.reduce(opts, message, fn {key, value}, acc ->
String.replace(acc, "%{#{key}}", to_string(value))
end)
end)
end
end