Fixes https://github.com/thoughtbot/administrate/issues/1860
We show a "required" asterisk when fields are required. However there are some edge cases, like when the requirement has an if/unless. We don't consider those actually required and we don't show the asterisk there.
But there are other edge cases. Issue #1860 (closed) shows how the validation option :on
can also create cases where an apparent requirement is not actually a requirement. Normally this option has the values :create
or :update
, but there are other possibilities.
This PR tries to solve the issue. There are three commits, each an incremental improvement:
- Consider
:on
to be the same as:if
and:unless
, and hide the asterisk. - Refactor specs to avoid the mystery guests involved in the examples for
:if
,:unless
, and:on
. This also allows for more scalable specs, should we decide to add more fine-grained handling of these options. - Consider the special (and most common) cases of
on: :create
andon: :update
, and hide the asterisk for any other:on
value.
So we could go just with the first commit, or the first two, or the whole thing. Or more than that! Opinions?