Gestionnaire can see archived file

This commit is contained in:
Xavier J 2015-11-27 15:04:24 +01:00
parent a79ecbba6d
commit 1e1a6b3693
2 changed files with 9 additions and 5 deletions

View file

@ -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)

View file

@ -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') }