From 27f14954b689f20db87866f31bb4c039fddf74e8 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Wed, 6 Nov 2024 16:08:35 +0100 Subject: [PATCH] add-spec-for-sorted-by-labels --- spec/services/dossier_filter_service_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/services/dossier_filter_service_spec.rb b/spec/services/dossier_filter_service_spec.rb index c1dbc539a..98a80bd8e 100644 --- a/spec/services/dossier_filter_service_spec.rb +++ b/spec/services/dossier_filter_service_spec.rb @@ -273,6 +273,23 @@ describe DossierFilterService do it { is_expected.to eq([dossier_no, dossier_yes].map(&:id)) } end + context 'for labels table' do + let(:column) { procedure.find_column(label: 'Labels') } + let(:order) { 'asc' } + + let(:label_a) { Label.create(name: "a", color: 'green-bourgeon', procedure:) } + let(:label_z) { Label.create(name: "z", color: 'green-bourgeon', procedure:) } + let!(:dossier_a) { create(:dossier, procedure:) } + let!(:dossier_z) { create(:dossier, procedure:) } + let(:dossier_label_a) { DossierLabel.create(dossier: dossier_a, label: label_a) } + let(:dossier_label_z) { DossierLabel.create(dossier: dossier_z, label: label_z) } + + before do + end + + it { is_expected.to eq([dossier_a, dossier_z].map(&:id)) } + end + context 'for other tables' do # All other columns and tables work the same so it’s ok to test only one let(:column) { procedure.find_column(label: 'Établissement code postal') }