Merge pull request #9329 from tchak/fix-purge-motivation-after-repasser-en-instruction
ETQ instructeur, je veux que la motivation soit effacée lorsque je repasse un dossier en instruction
This commit is contained in:
commit
c4dfd45a22
3 changed files with 26 additions and 1 deletions
|
@ -980,6 +980,9 @@ class Dossier < ApplicationRecord
|
|||
.processed_at
|
||||
attestation&.destroy
|
||||
|
||||
self.motivation = nil
|
||||
self.justificatif_motivation.purge_later
|
||||
|
||||
save!
|
||||
rebase_later
|
||||
if !disable_notification
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: purge_motivation_dossiers_not_termine'
|
||||
task purge_motivation_dossiers_not_termine: :environment do
|
||||
puts "Running deploy task 'purge_motivation_dossiers_not_termine'"
|
||||
|
||||
dossier_with_justificatif_motivation_ids = ActiveStorage::Attachment.where(name: 'justificatif_motivation').pluck(:record_id).uniq
|
||||
dossiers = Dossier.where(id: dossier_with_justificatif_motivation_ids).state_not_termine
|
||||
progress = ProgressReport.new(dossiers.count)
|
||||
|
||||
dossiers.find_each do |dossier|
|
||||
dossier.justificatif_motivation.purge_later
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
|
@ -1458,7 +1458,7 @@ describe Dossier, type: :model do
|
|||
end
|
||||
|
||||
describe '#repasser_en_instruction!' do
|
||||
let(:dossier) { create(:dossier, :refuse, :with_attestation, archived: true, termine_close_to_expiration_notice_sent_at: Time.zone.now) }
|
||||
let(:dossier) { create(:dossier, :refuse, :with_attestation, :with_justificatif, archived: true, termine_close_to_expiration_notice_sent_at: Time.zone.now) }
|
||||
let!(:instructeur) { create(:instructeur) }
|
||||
let(:last_operation) { dossier.dossier_operation_logs.last }
|
||||
|
||||
|
@ -1474,6 +1474,7 @@ describe Dossier, type: :model do
|
|||
it { expect(dossier.archived).to be_falsey }
|
||||
it { expect(dossier.processed_at).to be_nil }
|
||||
it { expect(dossier.motivation).to be_nil }
|
||||
it { expect(dossier.justificatif_motivation.attached?).to be_falsey }
|
||||
it { expect(dossier.attestation).to be_nil }
|
||||
it { expect(dossier.termine_close_to_expiration_notice_sent_at).to be_nil }
|
||||
it { expect(last_operation.operation).to eq('repasser_en_instruction') }
|
||||
|
|
Loading…
Reference in a new issue