Disable Messagerie in archived Dossiers and procedures

* 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.
This commit is contained in:
Nicolas Bouilleaud 2019-06-20 09:58:53 +02:00
parent 8febe8c21f
commit bd47bf2691
8 changed files with 58 additions and 5 deletions

View file

@ -12,6 +12,9 @@ class CommentaireService
end
def build_with_email(email, dossier, params)
if !dossier.messagerie_available?
raise ArgumentError, "Commentaires cannot be added to brouillons or archived Dossiers"
end
attributes = params.merge(email: email, dossier: dossier)
Commentaire.new(attributes)
end