- Make `champ.dossier` a requirement;
- Move the dossier_id assignation to `before_validation` (otherwise
the record is invalid, and never gets saved);
- Allow specs to only build the champ (instead of saving it to the
database), which bypasses the requirement to have a dossier.
We currently have many failed VirusScannerJob enqueued, because the
underlying blob is missing.
This PR fixes the issue by discarding the job in those cases (because if
the blob is gone, the job is never going to succeed).
The implementation is based on a similar issue encoutered by the
ActiveStorage::AnalyzeJob. See 06f8baf73c
When the job is invoked directly, the serialization and de-serialization
of the job arguments is not actually tested.
Using `perform_later` inside a `perform_enqueued_jobs` allows to
exercise the serialization.