use traitement model

when a dossier is terminated (accepte, refuse or classe_sans_suite),
we store now `processed_at` and `motivation` in a traitement instance
This commit is contained in:
Christophe Robillard 2020-07-02 11:02:50 +02:00
parent f631acd118
commit a072d35211
14 changed files with 107 additions and 29 deletions

View file

@ -35,6 +35,7 @@ describe TagsSubstitutionConcern, type: :model do
let(:individual) { nil }
let(:etablissement) { create(:etablissement) }
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: etablissement) }
let(:instructeur) { create(:instructeur) }
before { Timecop.freeze(Time.zone.now) }
@ -242,7 +243,7 @@ describe TagsSubstitutionConcern, type: :model do
end
context 'when the dossier has a motivation' do
let(:dossier) { create(:dossier, motivation: 'motivation') }
let(:dossier) { create(:dossier, :accepte, motivation: 'motivation') }
context 'and the template has some dossier tags' do
let(:template) { '--motivation-- --numéro du dossier--' }
@ -318,9 +319,13 @@ describe TagsSubstitutionConcern, type: :model do
context "when using a date tag" do
before do
dossier.en_construction_at = Time.zone.local(2001, 2, 3)
dossier.en_instruction_at = Time.zone.local(2004, 5, 6)
dossier.processed_at = Time.zone.local(2007, 8, 9)
Timecop.freeze(Time.zone.local(2001, 2, 3))
dossier.passer_en_construction!
Timecop.freeze(Time.zone.local(2004, 5, 6))
dossier.passer_en_instruction!(instructeur)
Timecop.freeze(Time.zone.local(2007, 8, 9))
dossier.accepter!(instructeur, nil, nil)
Timecop.return
end
context "with date de dépôt" do