diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 82a26f1ae..34d489f6f 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -233,9 +233,10 @@ class ProcedurePresentation < ApplicationRecord end def human_value_for_filter(filter) - case filter[TABLE] - when TYPE_DE_CHAMP, TYPE_DE_CHAMP_PRIVATE + if [TYPE_DE_CHAMP, TYPE_DE_CHAMP_PRIVATE].include?(filter[TABLE]) find_type_de_champ(filter[COLUMN]).dynamic_type.filter_to_human(filter['value']) + elsif filter['column'] == 'state' + Dossier.human_attribute_name("state.#{filter['value']}") else filter['value'] end diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index 4c75d1f62..0f7cae5ed 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -784,6 +784,14 @@ describe ProcedurePresentation do expect(subject).to eq("oui") end end + + context 'when filter is state' do + let(:filters) { { "suivis" => [{ "table" => "self", "column" => "state", "value" => "en_construction" }] } } + + it 'should get i18n value' do + expect(subject).to eq("En construction") + end + end end describe "#add_filter" do