From 985cf32752dddbc6363b36040f8d32ab9da4d205 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 20 Nov 2024 16:36:25 +0100 Subject: [PATCH] feat(champ siret): improve default base SIRET column wording --- app/models/types_de_champ/type_de_champ_base.rb | 7 ++++++- spec/models/types_de_champ/siret_type_de_champ_spec.rb | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/types_de_champ/type_de_champ_base.rb b/app/models/types_de_champ/type_de_champ_base.rb index 86ab644f5..4df247271 100644 --- a/app/models/types_de_champ/type_de_champ_base.rb +++ b/app/models/types_de_champ/type_de_champ_base.rb @@ -116,7 +116,12 @@ class TypesDeChamp::TypeDeChampBase private def libelle_with_prefix(prefix) - [prefix, libelle].compact.join(' – ') + # SIRET needs to be explicit in listings for better UI readability + if type_champ == "siret" && !libelle.upcase.include?("SIRET") + [prefix, libelle, "SIRET"].compact.join(' – ') + else + [prefix, libelle].compact.join(' – ') + end end def paths diff --git a/spec/models/types_de_champ/siret_type_de_champ_spec.rb b/spec/models/types_de_champ/siret_type_de_champ_spec.rb index 1188c1762..3dc47d20d 100644 --- a/spec/models/types_de_champ/siret_type_de_champ_spec.rb +++ b/spec/models/types_de_champ/siret_type_de_champ_spec.rb @@ -7,6 +7,16 @@ describe TypesDeChamp::SiretTypeDeChamp do describe "#columns" do subject(:columns) { tdc_siret.columns(procedure: procedure) } + it "returns base column without duplicating SIRET when already in libelle" do + expect(columns[0].label).to eq("Numéro SIRET") + end + + it "returns base column with SIRET when libelle doesn't contain SIRET" do + tdc_siret.update(libelle: "Identification de l'entreprise") + + expect(columns[0].label).to eq("Identification de l'entreprise – SIRET") + end + it "includes required jsonpaths" do expected_paths = [ "$.entreprise_raison_sociale",