[#2675] Fix notification sort order

This commit is contained in:
Frederic Merizen 2018-10-23 18:48:05 +02:00
parent 02f4ef215a
commit 64cb231b01
2 changed files with 9 additions and 1 deletions

View file

@ -78,7 +78,7 @@ class ProcedurePresentation < ApplicationRecord
case table
when 'notifications'
dossiers_id_with_notification = gestionnaire.notifications_for_procedure(procedure)
dossiers_id_with_notification = gestionnaire.dossiers_id_with_notifications(dossiers)
if order == 'desc'
return dossiers_id_with_notification +
(dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)

View file

@ -238,6 +238,7 @@ describe ProcedurePresentation do
before do
notified_dossier.champs.first.touch(time: DateTime.new(2018, 9, 20))
create(:follow, gestionnaire: gestionnaire, dossier: notified_dossier, demande_seen_at: DateTime.new(2018, 9, 10))
notified_dossier.touch(time: DateTime.new(2018, 9, 20))
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
older_dossier.touch(time: DateTime.new(2018, 5, 13))
end
@ -253,6 +254,13 @@ describe ProcedurePresentation do
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
end
context 'with a dossier terminé' do
let!(:notified_dossier) { create(:dossier, :accepte, procedure: procedure) }
let(:order) { 'desc' }
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
end
end
context 'for self table' do