feat(administrateur): add environment variable for Administrateur::UNUSED_ADMIN_THRESHOLD
This commit is contained in:
parent
1dfb3817e6
commit
243b8c239a
3 changed files with 16 additions and 1 deletions
|
@ -8,7 +8,7 @@
|
||||||
# user_id :bigint not null
|
# user_id :bigint not null
|
||||||
#
|
#
|
||||||
class Administrateur < ApplicationRecord
|
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_and_belongs_to_many :instructeurs
|
||||||
has_many :administrateurs_procedures
|
has_many :administrateurs_procedures
|
||||||
|
|
|
@ -140,6 +140,9 @@ VITE_LEGACY=""
|
||||||
# around july 2022, we changed the duree_conservation_dossiers_dans_ds, allow instances to choose their own duration
|
# around july 2022, we changed the duree_conservation_dossiers_dans_ds, allow instances to choose their own duration
|
||||||
NEW_MAX_DUREE_CONSERVATION=12
|
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
|
# Open data
|
||||||
OPENDATA_ENABLED="enabled" # disabled by default if `OPENDATA_ENABLED` not set
|
OPENDATA_ENABLED="enabled" # disabled by default if `OPENDATA_ENABLED` not set
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,18 @@ describe Administrateur, type: :model do
|
||||||
|
|
||||||
it { is_expected.to be_empty }
|
it { is_expected.to be_empty }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'zones' do
|
describe 'zones' do
|
||||||
|
|
Loading…
Reference in a new issue