hide dossier with accuse de lecture in user list when using state filter
This commit is contained in:
parent
5bbc4cab50
commit
1cf3db5899
2 changed files with 39 additions and 20 deletions
|
@ -23,6 +23,7 @@ class DossiersFilter
|
|||
dossiers_result = dossiers
|
||||
dossiers_result = dossiers_result.where(state: state) if state.present? && state != Dossier::A_CORRIGER
|
||||
dossiers_result = dossiers_result.with_pending_corrections if state.present? && state == Dossier::A_CORRIGER
|
||||
dossiers_result = exclude_accuse_lecture(dossiers_result) if state.present? && Dossier::TERMINE.include?(state)
|
||||
dossiers_result = dossiers_result.where('dossiers.created_at >= ?', from_created_at_date) if from_created_at_date.present?
|
||||
dossiers_result = dossiers_result.where('dossiers.depose_at >= ?', from_depose_at_date) if from_depose_at_date.present?
|
||||
dossiers_result
|
||||
|
@ -47,4 +48,8 @@ class DossiersFilter
|
|||
rescue Date::Error
|
||||
nil
|
||||
end
|
||||
|
||||
def exclude_accuse_lecture(dossiers)
|
||||
dossiers.joins(:procedure).where.not('dossiers.accuse_lecture_agreement_at IS NULL AND procedures.accuse_lecture = TRUE ')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
describe 'user access to the list of their dossiers', js: true do
|
||||
let(:user) { create(:user) }
|
||||
let(:procedure_accuse_lecture) { create(:procedure, :accuse_lecture) }
|
||||
let!(:dossier_brouillon) { create(:dossier, user: user) }
|
||||
let!(:dossier_en_construction) { create(:dossier, :with_populated_champs, :en_construction, user: user) }
|
||||
let!(:dossier_en_construction_2) { create(:dossier, :en_construction, user: user) }
|
||||
|
@ -9,6 +10,8 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
let!(:dossier_a_corriger) { create(:dossier_correction, dossier: dossier_en_construction_2) }
|
||||
let!(:dossier_archived) { create(:dossier, :en_instruction, :archived, user: user) }
|
||||
let!(:dossier_for_tiers) { create(:dossier, :en_instruction, :for_tiers_with_notification, user: user) }
|
||||
let!(:dossier_en_construction_with_accuse_lecture) { create(:dossier, :en_construction, user: user, procedure: procedure_accuse_lecture) }
|
||||
let!(:dossier_accepte_with_accuse_lecture) { create(:dossier, :accepte, user: user, procedure: procedure_accuse_lecture) }
|
||||
let(:dossiers_per_page) { 25 }
|
||||
let(:last_updated_dossier) { dossier_en_construction }
|
||||
|
||||
|
@ -31,8 +34,8 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
expect(page).to have_content(dossier_en_construction.procedure.libelle)
|
||||
expect(page).to have_content(dossier_en_instruction.procedure.libelle)
|
||||
expect(page).to have_content(dossier_archived.procedure.libelle)
|
||||
expect(page).to have_text('6 en cours')
|
||||
expect(page).to have_text('2 traités')
|
||||
expect(page).to have_text('7 en cours')
|
||||
expect(page).to have_text('3 traités')
|
||||
end
|
||||
|
||||
it 'the list must be ordered by last updated' do
|
||||
|
@ -55,8 +58,8 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
page.click_link("Suivant")
|
||||
page.click_link("Suivant")
|
||||
expect(page).to have_link(dossier_en_instruction.procedure.libelle)
|
||||
expect(page).to have_text('6 en cours')
|
||||
expect(page).to have_text('2 traités')
|
||||
expect(page).to have_text('7 en cours')
|
||||
expect(page).to have_text('3 traités')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -70,9 +73,9 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
|
||||
context 'when user uses filter' do
|
||||
scenario 'user filters state on tab "en-cours"' do
|
||||
expect(page).to have_text('6 en cours')
|
||||
expect(page).to have_text('2 traités')
|
||||
expect(page).to have_text('6 sur 6 dossiers')
|
||||
expect(page).to have_text('7 en cours')
|
||||
expect(page).to have_text('3 traités')
|
||||
expect(page).to have_text('7 sur 7 dossiers')
|
||||
|
||||
click_on('Sélectionner un filtre')
|
||||
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Brouillon', 'En construction', 'En instruction', 'À corriger']
|
||||
|
@ -92,9 +95,9 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
|
||||
scenario 'user filters state on tab "traité"' do
|
||||
visit dossiers_path(statut: 'traites')
|
||||
expect(page).to have_text('6 en cours')
|
||||
expect(page).to have_text('2 traités')
|
||||
expect(page).to have_text('2 sur 2 dossiers')
|
||||
expect(page).to have_text('7 en cours')
|
||||
expect(page).to have_text('3 traités')
|
||||
expect(page).to have_text('3 sur 3 dossiers')
|
||||
|
||||
click_on('Sélectionner un filtre')
|
||||
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Accepté', 'Refusé', 'Classé sans suite']
|
||||
|
@ -105,18 +108,29 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
|
||||
click_on('Sélectionner un filtre')
|
||||
click_on('Annuler')
|
||||
expect(page).to have_text('2 sur 2 dossiers')
|
||||
|
||||
click_on('Sélectionner un filtre')
|
||||
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Accepté', 'Refusé', 'Classé sans suite']
|
||||
select('Accepté', from: 'Statut')
|
||||
click_on('Appliquer les filtres')
|
||||
# we expect 1 dossier because we want do hide decision for dossier with accuse de lecture
|
||||
expect(page).to have_text('1 dossier')
|
||||
expect(page).to have_select 'Statut', selected: 'Accepté', options: ['Sélectionner un statut', 'Accepté', 'Refusé', 'Classé sans suite']
|
||||
|
||||
click_on('Sélectionner un filtre')
|
||||
click_on('Annuler')
|
||||
expect(page).to have_text('3 sur 3 dossiers')
|
||||
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Accepté', 'Refusé', 'Classé sans suite']
|
||||
end
|
||||
|
||||
scenario 'user filters by created_at' do
|
||||
dossier_en_construction.update!(created_at: Date.yesterday)
|
||||
|
||||
expect(page).to have_text('6 sur 6 dossiers')
|
||||
expect(page).to have_text('7 sur 7 dossiers')
|
||||
click_on('Sélectionner un filtre')
|
||||
fill_in 'from_created_at_date', with: Date.today
|
||||
click_on('Appliquer les filtres')
|
||||
expect(page).to have_text('5 sur 5 dossiers')
|
||||
expect(page).to have_text('6 sur 6 dossiers')
|
||||
end
|
||||
|
||||
scenario 'user uses multiple filters' do
|
||||
|
@ -124,26 +138,26 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
|
||||
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Brouillon', 'En construction', 'En instruction', 'À corriger']
|
||||
|
||||
expect(page).to have_text('6 sur 6 dossiers')
|
||||
expect(page).to have_text('7 sur 7 dossiers')
|
||||
click_on('Sélectionner un filtre')
|
||||
fill_in 'from_created_at_date', with: Date.today
|
||||
click_on('Appliquer les filtres')
|
||||
expect(page).to have_text('5 sur 5 dossiers')
|
||||
expect(page).to have_text('6 sur 6 dossiers')
|
||||
expect(page).to have_text('1 filtre actif')
|
||||
|
||||
click_on('Sélectionner un filtre')
|
||||
select('En construction', from: 'Statut')
|
||||
click_on('Appliquer les filtres')
|
||||
expect(page).to have_text('1 dossier')
|
||||
expect(page).to have_text('2 dossiers')
|
||||
expect(page).to have_text('2 filtres actifs')
|
||||
|
||||
click_on('Sélectionner un filtre')
|
||||
fill_in 'from_depose_at_date', with: Date.today
|
||||
click_on('Appliquer les filtres')
|
||||
expect(page).to have_text('1 dossier')
|
||||
expect(page).to have_text('2 sur 2 dossiers')
|
||||
expect(page).to have_text('3 filtres actifs')
|
||||
click_on('3 filtres actifs')
|
||||
expect(page).to have_text('6 sur 6 dossiers')
|
||||
expect(page).to have_text('7 sur 7 dossiers')
|
||||
expect(page).not_to have_text('5 filtres actifs')
|
||||
end
|
||||
end
|
||||
|
@ -285,8 +299,8 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
describe "filter by procedure" do
|
||||
context "when dossiers are on different procedures" do
|
||||
it "can filter by procedure" do
|
||||
expect(page).to have_text('6 en cours')
|
||||
expect(page).to have_text('2 traités')
|
||||
expect(page).to have_text('7 en cours')
|
||||
expect(page).to have_text('3 traités')
|
||||
expect(page).to have_select('procedure_id', selected: 'Toutes les démarches')
|
||||
select dossier_brouillon.procedure.libelle, from: 'procedure_id'
|
||||
expect(page).to have_text('1 en cours')
|
||||
|
|
Loading…
Reference in a new issue