PiecesJustificativesService: save_pj returns nil if no errors
This commit is contained in:
parent
c103e55579
commit
e0828dda13
2 changed files with 3 additions and 3 deletions
|
@ -12,7 +12,7 @@ class PiecesJustificativesService
|
|||
|
||||
errors += without_virus
|
||||
.map { |tpj, content| save_pj(content, dossier, tpj, user) }
|
||||
.reject(&:empty?)
|
||||
.compact()
|
||||
|
||||
errors += missing_pj_error_messages(dossier)
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ class PiecesJustificativesService
|
|||
type_de_piece_justificative: tpj,
|
||||
user: user)
|
||||
|
||||
pj.save ? '' : "le fichier #{pj.libelle} n'a pas pu être sauvegardé"
|
||||
pj.save ? nil : "le fichier #{pj.libelle} n'a pas pu être sauvegardé"
|
||||
end
|
||||
|
||||
def self.missing_pj_error_messages(dossier)
|
||||
|
|
|
@ -63,7 +63,7 @@ describe PiecesJustificativesService do
|
|||
# we are messing around piece_justificative
|
||||
# because directly doubling carrierwave params seems complicated
|
||||
|
||||
allow(PiecesJustificativesService).to receive(:save_pj).and_return('')
|
||||
allow(PiecesJustificativesService).to receive(:save_pj).and_return(nil)
|
||||
piece_justificative_double = double(type_de_piece_justificative: tpj_mandatory)
|
||||
expect(dossier).to receive(:pieces_justificatives).and_return([piece_justificative_double])
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue