2024-03-04 10:52:49 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "rails_helper"
|
|
|
|
|
|
|
|
module Maintenance
|
|
|
|
RSpec.describe SpreadDossierDeletionTask do
|
|
|
|
describe "#process" do
|
|
|
|
let(:dossiers) { Dossier.all }
|
2024-03-05 14:25:16 +01:00
|
|
|
before do
|
|
|
|
create(:dossier, termine_close_to_expiration_notice_sent_at: Maintenance::SpreadDossierDeletionTask::ERROR_OCCURED_AT + 1.hour)
|
|
|
|
create(:dossier, termine_close_to_expiration_notice_sent_at: Maintenance::SpreadDossierDeletionTask::ERROR_OCCURED_AT + 2.hours)
|
|
|
|
create(:dossier, termine_close_to_expiration_notice_sent_at: Maintenance::SpreadDossierDeletionTask::ERROR_OCCURED_AT + 3.hours)
|
|
|
|
create(:dossier, termine_close_to_expiration_notice_sent_at: Maintenance::SpreadDossierDeletionTask::ERROR_OCCURED_AT + 4.hours)
|
|
|
|
end
|
2024-03-04 10:52:49 +01:00
|
|
|
subject(:process) { described_class.process(dossiers) }
|
|
|
|
|
|
|
|
it "works" do
|
2024-03-05 14:25:16 +01:00
|
|
|
expect { subject }.to change { Dossier.where(termine_close_to_expiration_notice_sent_at: Maintenance::SpreadDossierDeletionTask::ERROR_OCCURED_RANGE).count }
|
|
|
|
.from(4).to(0)
|
2024-03-04 10:52:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|