Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !1872

Correct "required" asterisk when using validation option `:on`

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Pablo Brasero requested to merge github/fork/pablobm/fix-required-on into master Jan 21, 2021
  • Overview 2
  • Commits 3
  • Pipelines 0
  • Changes 5

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:

  1. Consider :on to be the same as :if and :unless, and hide the asterisk.
  2. 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.
  3. Consider the special (and most common) cases of on: :create and on: :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?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/pablobm/fix-required-on