From 06f43f99d00f9ea6d09dddfcc1ef2132aea58670 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 29 Nov 2022 16:14:24 +0100 Subject: [PATCH] fix(dossier): excluded deleted dossiers from demarche overview --- app/models/procedure_overview.rb | 3 +-- spec/models/procedure_overview_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/procedure_overview.rb b/app/models/procedure_overview.rb index 16076eda8..fd8a4e9ee 100644 --- a/app/models/procedure_overview.rb +++ b/app/models/procedure_overview.rb @@ -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 diff --git a/spec/models/procedure_overview_spec.rb b/spec/models/procedure_overview_spec.rb index 90815a81d..f27e4547f 100644 --- a/spec/models/procedure_overview_spec.rb +++ b/spec/models/procedure_overview_spec.rb @@ -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