From 1e1a6b3693ded158662935925435ca605f7c6b3a Mon Sep 17 00:00:00 2001 From: Xavier J Date: Fri, 27 Nov 2015 15:04:24 +0100 Subject: [PATCH] Gestionnaire can see archived file --- app/models/dossier.rb | 9 +++++---- spec/models/dossier_spec.rb | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 428781566..5332e3720 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -134,15 +134,15 @@ class Dossier < ActiveRecord::Base end def self.a_traiter current_gestionnaire - current_gestionnaire.dossiers.where(state: A_TRAITER).order('updated_at ASC') + current_gestionnaire.dossiers.where(state: A_TRAITER, archived: false).order('updated_at ASC') end def self.en_attente current_gestionnaire - current_gestionnaire.dossiers.where(state: EN_ATTENTE).order('updated_at ASC') + current_gestionnaire.dossiers.where(state: EN_ATTENTE, archived: false).order('updated_at ASC') end def self.termine current_gestionnaire - current_gestionnaire.dossiers.where(state: TERMINE).order('updated_at ASC') + current_gestionnaire.dossiers.where(state: TERMINE, archived: false).order('updated_at ASC') end def self.search current_gestionnaire, terms @@ -171,7 +171,8 @@ class Dossier < ActiveRecord::Base #TODO refactor composed_scope = composed_scope.where( dossiers[:id].eq_any(current_gestionnaire.dossiers.ids).and\ - dossiers[:state].does_not_match('draft')) + dossiers[:state].does_not_match('draft').and\ + dossiers[:archived].eq(false)) begin if Float(terms) && terms.to_i <= 2147483647 && current_gestionnaire.dossiers.ids.include?(terms.to_i) diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 0d5527dd8..ab14eda97 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -398,7 +398,9 @@ describe Dossier do let!(:dossier7) { create(:dossier, :with_user, procedure: procedure_admin_2, state: 'submitted') } #a_traiter let!(:dossier8) { create(:dossier, :with_user, procedure: procedure_admin_2, state: 'closed') } #termine let!(:dossier9) { create(:dossier, :with_user, procedure: procedure_admin, state: 'closed') } #termine - + let!(:dossier10) { create(:dossier, :with_user, procedure: procedure_admin, state: 'initiated', archived: true) } #a_traiter #archived + let!(:dossier11) { create(:dossier, :with_user, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived + let!(:dossier12) { create(:dossier, :with_user, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived describe '#a_traiter' do subject { described_class.a_traiter gestionnaire } @@ -438,6 +440,7 @@ describe Dossier do let!(:dossier_1) { create(:dossier, nom_projet: 'Projet de test', state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) } let!(:dossier_2) { create(:dossier, nom_projet: 'Lili et Marcel', state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) } let!(:dossier_3) { create(:dossier, nom_projet: 'Construction projet marcel', state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) } + let!(:dossier_archived) { create(:dossier, nom_projet: 'je suis un Marcel archivé', state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) } let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') } let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') }