Merge pull request #9352 from adullact/feature-ouidou/env_var_for_admin_unused_threshold

feat(administrateur): add environment variable for Administrateur::UNUSED_ADMIN_THRESHOLD
This commit is contained in:
Paul Chavard 2023-07-25 08:29:37 +00:00 committed by GitHub
commit 328f90275f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View file

@ -8,7 +8,7 @@
# user_id :bigint not null
#
class Administrateur < ApplicationRecord
UNUSED_ADMIN_THRESHOLD = 6.months
UNUSED_ADMIN_THRESHOLD = ENV.fetch('UNUSED_ADMIN_THRESHOLD') { 6 }.to_i.months
has_and_belongs_to_many :instructeurs
has_many :administrateurs_procedures

View file

@ -140,6 +140,9 @@ VITE_LEGACY=""
# around july 2022, we changed the duree_conservation_dossiers_dans_ds, allow instances to choose their own duration
NEW_MAX_DUREE_CONSERVATION=12
#number of months after which DS considere an administrateur useless (if no service and no procedure)
#UNUSED_ADMIN_THRESHOLD=6
# Open data
OPENDATA_ENABLED="enabled" # disabled by default if `OPENDATA_ENABLED` not set

View file

@ -232,6 +232,18 @@ describe Administrateur, type: :model do
it { is_expected.to be_empty }
end
context 'with a custom longer threshold period' do
before { stub_const("Administrateur::UNUSED_ADMIN_THRESHOLD", 7.months) }
it { is_expected.to be_empty }
end
context 'with a custom shorter threshold period' do
before { stub_const("Administrateur::UNUSED_ADMIN_THRESHOLD", 5.months) }
it { is_expected.to match([new_admin, unused_admin]) }
end
end
describe 'zones' do