Validate that a dossier on a `for_individual?` procedure always has
an `individual` associated record.
For this, the individual needs to be built before the record is
validated (i.e. even before the `before_create` callback is run).
This should help with #4596: now if a dossier is created without an
`individual`, or if the `invividual` record is later removed, the
validation will fail.
The code paths for deleting a dossier were different, depending on
whether the dossier was deleted by the user, or from the Manager.
This commit unifies the two code paths into one.
This has the effect of:
- An operation log is now recorded when an user deletes its own dossier;
- Gestionnaires are now notified even when the dossier is deleted from
the Manager;
- The `support:delete_user_account` task now requires the email address
of the author.
An Admin may archive a procedure to make it unavailable to
the general public, but before all dossiers are handled. In this case,
the messagerie needs to be available.
Fix#4089
* Use the existing Dossier#messagerie_available? method
* Raise when attempting to build a Commentaire if not messagerie_available?
* Disable the Messagerie form if not messagerie_available?
* Add tests :)
* Tweak the Horaires formatting while we’re here.
The `nearing_end_of_retention` test creates a `just_expired_dossier` “six months ago”, which is 29 Oct 2018. The autumn DST change was on October 28; this is the first time this test runs under these conditions. We workaround the time offset by creating the dossier one hour earlier.
This is technically a workaround, not a fix: the date arithmetics in `nearing_end_of_retention` are probably wrong. It looks like it’s comparing intervals, which seems error-prone, while it should be comparing dates. For now, I’m just making the tests pass.