Merge pull request #6892 from tchak/fix-admin-for-a-day

fix(manager): remove admins added for a day
This commit is contained in:
Paul Chavard 2022-02-08 11:25:21 +01:00 committed by GitHub
commit d11b457838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -2,6 +2,7 @@ class Cron::PurgeManagerAdministrateurSessionsJob < Cron::CronJob
self.schedule_expression = "every day at 3 am" self.schedule_expression = "every day at 3 am"
def perform 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
end end

View file

@ -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