From 9fc195f0e52d8c838cc76703f313de19fdc9bf55 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 7 Sep 2021 14:27:07 +0200 Subject: [PATCH] add test to dossier_projection_service --- .../dossier_projection_service_spec.rb | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/services/dossier_projection_service_spec.rb b/spec/services/dossier_projection_service_spec.rb index 243f81084..096ac0e07 100644 --- a/spec/services/dossier_projection_service_spec.rb +++ b/spec/services/dossier_projection_service_spec.rb @@ -184,6 +184,33 @@ describe DossierProjectionService do it { is_expected.to eq('18 a la bonne rue') } end + + context 'for type_de_champ table: type_de_champ pays which needs external_id field' do + let(:table) { 'type_de_champ' } + let(:procedure) { create(:procedure, types_de_champ: [build(:type_de_champ_pays)]) } + let(:dossier) { create(:dossier, procedure: procedure) } + let(:column) { dossier.procedure.types_de_champ.first.stable_id.to_s } + let!(:previous_locale) { I18n.locale } + + before { I18n.locale = :fr } + after { I18n.locale = previous_locale } + + context 'when external id is set' do + before do + dossier.champs.first.update(external_id: 'GB') + end + + it { is_expected.to eq('Royaume-Uni') } + end + + context 'when no external id is set' do + before do + dossier.champs.first.update(value: "qu'il est beau mon pays") + end + + it { is_expected.to eq("qu'il est beau mon pays") } + end + end end end end