style(instructeurs): human/i18n value for state filter

This commit is contained in:
Colin Darie 2022-12-14 23:13:54 +01:00
parent 7ff6455440
commit 7ff04c1a05
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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