parent
f0de64a787
commit
0268511264
2 changed files with 24 additions and 1 deletions
|
@ -2,6 +2,7 @@ class Cron::PurgeManagerAdministrateurSessionsJob < Cron::CronJob
|
|||
self.schedule_expression = "every day at 3 am"
|
||||
|
||||
def perform
|
||||
AdministrateursProcedure.where(manager: true).destroy_all
|
||||
# TODO: add id column to administrateurs_procedures and use destroy_all
|
||||
AdministrateursProcedure.where(manager: true).delete_all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
RSpec.describe Cron::PurgeManagerAdministrateurSessionsJob, type: :job do
|
||||
describe 'perform' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
|
||||
subject { Cron::PurgeManagerAdministrateurSessionsJob.perform_now }
|
||||
|
||||
context "with an inactive administrateur" do
|
||||
before do
|
||||
AdministrateursProcedure.create(procedure: procedure, administrateur: administrateur, manager: true)
|
||||
expect(AdministrateursProcedure.where(manager: true).count).to eq(1)
|
||||
expect(AdministrateursProcedure.count).to eq(2)
|
||||
subject
|
||||
end
|
||||
|
||||
it {
|
||||
expect(AdministrateursProcedure.where(manager: true).count).to eq(0)
|
||||
expect(AdministrateursProcedure.count).to eq(1)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue