fix sort in procedure presentation
This commit is contained in:
parent
66c1430fc0
commit
9fd5219751
2 changed files with 29 additions and 1 deletions
|
@ -195,7 +195,7 @@ class ProcedurePresentation < ApplicationRecord
|
|||
dossiers_sorted_ids = self.sorted_ids(dossiers_by_statut, count || dossiers_by_statut.size)
|
||||
|
||||
if filters[statut].present?
|
||||
filtered_ids(dossiers_by_statut, statut).intersection(dossiers_sorted_ids)
|
||||
dossiers_sorted_ids.intersection(filtered_ids(dossiers_by_statut, statut))
|
||||
else
|
||||
dossiers_sorted_ids
|
||||
end
|
||||
|
|
|
@ -768,4 +768,32 @@ describe ProcedurePresentation do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#filtered_sorted_ids' do
|
||||
let(:dossier_1) { create(:dossier) }
|
||||
let(:dossier_2) { create(:dossier) }
|
||||
let(:dossier_3) { create(:dossier) }
|
||||
let(:dossiers) { Dossier.where(id: [dossier_1, dossier_2, dossier_3].map(&:id)) }
|
||||
|
||||
let(:sorted_ids) { [dossier_2, dossier_3, dossier_1].map(&:id) }
|
||||
|
||||
subject { procedure_presentation.filtered_sorted_ids(dossiers, 'tous') }
|
||||
|
||||
before do
|
||||
expect(procedure_presentation).to receive(:sorted_ids).and_return(sorted_ids)
|
||||
end
|
||||
|
||||
it { is_expected.to eq(sorted_ids) }
|
||||
|
||||
context 'when a filter is present' do
|
||||
let(:filtered_ids) { [dossier_1, dossier_2, dossier_3].map(&:id) }
|
||||
|
||||
before do
|
||||
procedure_presentation.filters['tous'] = 'some_filter'
|
||||
expect(procedure_presentation).to receive(:filtered_ids).and_return(filtered_ids)
|
||||
end
|
||||
|
||||
it { is_expected.to eq(sorted_ids) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue