[#2675] Fix notification sort order
This commit is contained in:
parent
02f4ef215a
commit
64cb231b01
2 changed files with 9 additions and 1 deletions
|
@ -78,7 +78,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
|
|
||||||
case table
|
case table
|
||||||
when 'notifications'
|
when 'notifications'
|
||||||
dossiers_id_with_notification = gestionnaire.notifications_for_procedure(procedure)
|
dossiers_id_with_notification = gestionnaire.dossiers_id_with_notifications(dossiers)
|
||||||
if order == 'desc'
|
if order == 'desc'
|
||||||
return dossiers_id_with_notification +
|
return dossiers_id_with_notification +
|
||||||
(dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
(dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
||||||
|
|
|
@ -238,6 +238,7 @@ describe ProcedurePresentation do
|
||||||
before do
|
before do
|
||||||
notified_dossier.champs.first.touch(time: DateTime.new(2018, 9, 20))
|
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))
|
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))
|
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
||||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
||||||
end
|
end
|
||||||
|
@ -253,6 +254,13 @@ describe ProcedurePresentation do
|
||||||
|
|
||||||
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
|
it { is_expected.to eq([notified_dossier, recent_dossier, older_dossier].map(&:id)) }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'for self table' do
|
context 'for self table' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue