fix(dossier): excluded deleted dossiers from demarche overview

This commit is contained in:
Paul Chavard 2022-11-29 16:14:24 +01:00 committed by LeSim
parent 5eb489946d
commit 06f43f99d0
2 changed files with 8 additions and 2 deletions

View file

@ -10,7 +10,7 @@ class ProcedureOverview
@start_date = start_date
@procedure = procedure
dossiers = procedure.dossiers.where(groupe_instructeur: groups)
dossiers = procedure.dossiers.where(groupe_instructeur: groups).visible_by_administration
@dossiers_en_instruction_count = dossiers.state_en_instruction.count
@old_dossiers_en_instruction = dossiers
@ -24,7 +24,6 @@ class ProcedureOverview
@created_dossiers_count = dossiers
.where(created_at: start_date..Time.zone.now)
.state_not_brouillon
.count
end

View file

@ -34,6 +34,13 @@ describe ProcedureOverview, type: :model do
let!(:dossier_en_construction) do
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction), created_at: monday)
end
let(:dossier_en_construction_deleted_by_user) do
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction), created_at: monday)
end
before do
dossier_en_construction_deleted_by_user.update(hidden_by_user_at: Time.zone.now)
end
it { expect(procedure_overview.dossiers_en_construction_count).to eq(1) }
end