Merge pull request #6286 from betagouv/6207-fix-archives-update-dossiers

archives: ne met pas à jour un dossier après la génération de l'export pdf par un instructeur
This commit is contained in:
krichtof 2021-06-18 11:14:11 +02:00 committed by GitHub
commit 7bda735720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -56,7 +56,9 @@ class PiecesJustificativesService
include_infos_administration: true,
dossier: dossier
})
dossier.pdf_export_for_instructeur.attach(io: StringIO.open(pdf), filename: "export-#{dossier.id}.pdf", content_type: 'application/pdf')
ActiveRecord::Base.no_touching do
dossier.pdf_export_for_instructeur.attach(io: StringIO.open(pdf), filename: "export-#{dossier.id}.pdf", content_type: 'application/pdf')
end
dossier.pdf_export_for_instructeur
end

View file

@ -44,4 +44,18 @@ describe PiecesJustificativesService do
expect(subject.any? { |piece| piece.name == 'serialized' }).to be_truthy
end
end
describe '.generate_dossier_export' do
subject { PiecesJustificativesService.generate_dossier_export(dossier) }
it "generates pdf export for instructeur" do
subject
expect(dossier.pdf_export_for_instructeur).to be_attached
end
it "doesn't update dossier" do
before_export = Time.zone.now
subject
expect(dossier.updated_at).to be <= before_export
end
end
end