archives: don't update dossiers

this fix avoid to touch dossier after attaching pdf_export_for_instructeur
This commit is contained in:
Christophe Robillard 2021-06-18 09:06:05 +02:00
parent f64dedc872
commit fdec9b2fd5
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