diff --git a/.gitignore b/.gitignore index e2276072065..7b059a5afcd 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ storage/ yarn-debug.log* .yarn-integrity /.vscode +/.zed /.idea /public/assets /spec/support/spec_config.local.rb diff --git a/.rubocop.yml b/.rubocop.yml index c806ff7c174..a2214f9a3a0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1497,8 +1497,7 @@ Style/WhileUntilModifier: Enabled: false Style/WordArray: - Enabled: true - EnforcedStyle: brackets + Enabled: false Style/YodaCondition: Enabled: true diff --git a/app/assets/stylesheets/buttons.scss b/app/assets/stylesheets/buttons.scss index 1293eb49489..53fe0130c9a 100644 --- a/app/assets/stylesheets/buttons.scss +++ b/app/assets/stylesheets/buttons.scss @@ -374,7 +374,11 @@ ul.dropdown-items { padding: 2 * $default-spacer; &.large { - width: 340px; + width: 90vw; + + @media (min-width: 62em) { + width: 40vw; + } } ul { diff --git a/app/components/instructeurs/column_filter_component/column_filter_component.html.haml b/app/components/instructeurs/column_filter_component/column_filter_component.html.haml index c8b94293f59..0558fce588a 100644 --- a/app/components/instructeurs/column_filter_component/column_filter_component.html.haml +++ b/app/components/instructeurs/column_filter_component/column_filter_component.html.haml @@ -5,7 +5,7 @@ = current_filter_tags .fr-select-group - = label_tag :column, t('.column'), class: 'fr-label fr-m-0', id: 'instructeur-filter-combo-label', for: 'search-filter' + = label_tag :column, t('.column'), class: 'fr-label fr-mb-1w', id: 'instructeur-filter-combo-label', for: 'search-filter' %react-fragment = render ReactComponent.new "ComboBox/SingleComboBox", **filter_react_props diff --git a/app/jobs/api_entreprise/entreprise_job.rb b/app/jobs/api_entreprise/entreprise_job.rb index 1fe7c37fa26..403e9aaa757 100644 --- a/app/jobs/api_entreprise/entreprise_job.rb +++ b/app/jobs/api_entreprise/entreprise_job.rb @@ -5,5 +5,6 @@ def perform(etablissement_id, procedure_id) find_etablissement(etablissement_id) etablissement_params = APIEntreprise::EntrepriseAdapter.new(etablissement.siret, procedure_id).to_params etablissement.update!(etablissement_params) + etablissement.update_champ_value_json! end end diff --git a/app/models/column.rb b/app/models/column.rb index f41ce3cdb28..aea80775f92 100644 --- a/app/models/column.rb +++ b/app/models/column.rb @@ -50,6 +50,7 @@ def self.find(h_id) def dossier_column? = false def champ_column? = false + def filterable? = filterable def label_for_value(value) if options_for_select.present? diff --git a/app/models/columns/json_path_column.rb b/app/models/columns/json_path_column.rb index a60d5d8728d..9227a5e3db8 100644 --- a/app/models/columns/json_path_column.rb +++ b/app/models/columns/json_path_column.rb @@ -3,7 +3,7 @@ class Columns::JSONPathColumn < Columns::ChampColumn attr_reader :jsonpath - def initialize(procedure_id:, label:, stable_id:, tdc_type:, jsonpath:, options_for_select: [], displayable:, type: :text) + def initialize(procedure_id:, label:, stable_id:, tdc_type:, jsonpath:, options_for_select: [], displayable:, filterable: true, type: :text) @jsonpath = quote_string(jsonpath) super( @@ -12,6 +12,7 @@ def initialize(procedure_id:, label:, stable_id:, tdc_type:, jsonpath:, options_ stable_id:, tdc_type:, displayable:, + filterable:, type:, options_for_select: ) diff --git a/app/models/concerns/addressable_column_concern.rb b/app/models/concerns/addressable_column_concern.rb index b3a6edf7323..d96300a6790 100644 --- a/app/models/concerns/addressable_column_concern.rb +++ b/app/models/concerns/addressable_column_concern.rb @@ -6,10 +6,10 @@ module AddressableColumnConcern included do def addressable_columns(procedure:, displayable: true, prefix: nil) [ - ["code postal (5 chiffres)", '$.postal_code', :text, []], - ["commune", '$.city_name', :text, []], - ["département", '$.departement_code', :enum, APIGeoService.departement_options], - ["region", '$.region_name', :enum, APIGeoService.region_options] + ["Code postal (5 chiffres)", '$.postal_code', :text, []], + ["Commune", '$.city_name', :text, []], + ["Département", '$.departement_code', :enum, APIGeoService.departement_options], + ["Région", '$.region_name', :enum, APIGeoService.region_options] ].map do |(label, jsonpath, type, options_for_select)| Columns::JSONPathColumn.new( procedure_id: procedure.id, diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index d845bd7d7ba..d849b943861 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -154,17 +154,41 @@ def individual_columns end def moral_columns - etablissements = ['entreprise_forme_juridique', 'entreprise_siren', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social'] - .map { |column| dossier_col(table: 'etablissement', column:) } + siret_column = dossier_col(table: 'etablissement', column: :siret) - etablissement_dates = ['entreprise_date_creation'].map { |column| dossier_col(table: 'etablissement', column:, type: :date) } - - for_export = ["siege_social", "naf", "adresse", "numero_voie", "type_voie", "nom_voie", "complement_adresse", "localite", "code_insee_localite", "entreprise_siren", "entreprise_capital_social", "entreprise_numero_tva_intracommunautaire", "entreprise_forme_juridique_code", "entreprise_code_effectif_entreprise", "entreprise_etat_administratif", "entreprise_nom", "entreprise_prenom", "association_rna", "association_titre", "association_objet", "association_date_creation", "association_date_declaration", "association_date_publication"] - .map { |column| dossier_col(table: 'etablissement', column:, displayable: false, filterable: false) } - - other = ['siret', 'libelle_naf', 'code_postal'].map { |column| dossier_col(table: 'etablissement', column:) } + etablissements = Etablissement::DISPLAYABLE_COLUMNS.map do |(column, attributes)| + dossier_col(table: 'etablissement', column:, type: attributes[:type], filterable: attributes.fetch(:filterable, true)) + end - [etablissements, etablissement_dates, other, for_export].flatten + others = %w[code_postal].map { |column| dossier_col(table: 'etablissement', column:) } + + for_export = %w[ + siege_social + code_naf + adresse + numero_voie + type_voie + nom_voie + complement_adresse + localite + code_insee_localite + entreprise_capital_social + entreprise_numero_tva_intracommunautaire + entreprise_forme_juridique_code + entreprise_code_effectif_entreprise + entreprise_etat_administratif + entreprise_siret_siege_social + entreprise_nom + entreprise_prenom + association_rna + association_titre + association_objet + association_date_creation + association_date_declaration + association_date_publication + ].map { |column| dossier_col(table: 'etablissement', column:, displayable: false, filterable: false) } + + [siret_column, etablissements, others, for_export].flatten end def types_de_champ_columns diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb index ba523259884..132759dcc6b 100644 --- a/app/models/etablissement.rb +++ b/app/models/etablissement.rb @@ -21,6 +21,19 @@ class Etablissement < ApplicationRecord after_commit -> { dossier&.index_search_terms_later } + alias_attribute :code_naf, :naf + + # See https://github.com/demarches-simplifiees/demarches-simplifiees.fr/pull/10591#discussion_r1819399688 + # SIRET is already exposed as base column. + DISPLAYABLE_COLUMNS = { + "entreprise_raison_sociale" => { type: :text }, + "entreprise_siren" => { type: :text }, + "entreprise_nom_commercial" => { type: :text }, + "entreprise_forme_juridique" => { type: :text }, + "entreprise_date_creation" => { type: :date, filterable: false }, + "libelle_naf" => { type: :text } + }.freeze + def entreprise_raison_sociale read_attribute(:entreprise_raison_sociale).presence || raison_sociale_for_ei end @@ -193,6 +206,21 @@ def as_degraded_mode? adresse.nil? # TOOD: maybe dedicated column or more robust way end + def update_champ_value_json! + return if champ.nil? + + champ.update!(value_json: champ_value_json) + end + + def champ_value_json + address_data = APIGeoService.parse_etablissement_address(self) + + DISPLAYABLE_COLUMNS.keys.each_with_object(address_data) do |attr, hash| + value = public_send(attr) + hash[attr.to_sym] = value if value.present? + end + end + private def bilans_new_keys diff --git a/app/models/types_de_champ/siret_type_de_champ.rb b/app/models/types_de_champ/siret_type_de_champ.rb index 5786a071fa8..c0d6fe6ef76 100644 --- a/app/models/types_de_champ/siret_type_de_champ.rb +++ b/app/models/types_de_champ/siret_type_de_champ.rb @@ -10,6 +10,27 @@ def estimated_fill_duration(revision) def champ_blank_or_invalid?(champ) = Siret.new(siret: champ.value).invalid? def columns(procedure:, displayable: true, prefix: nil) - super.concat(addressable_columns(procedure:, displayable:, prefix:)) + super + .concat(etablissement_columns(procedure:, displayable:, prefix:)) + .concat(addressable_columns(procedure:, displayable:, prefix:)) + end + + private + + def etablissement_columns(procedure:, displayable:, prefix:) + i18n_scope = [:activerecord, :attributes, :procedure_presentation, :fields, :etablissement] + + Etablissement::DISPLAYABLE_COLUMNS.map do |(column, attributes)| + Columns::JSONPathColumn.new( + procedure_id: procedure.id, + stable_id:, + tdc_type: type_champ, + label: [prefix, libelle, I18n.t(column, scope: i18n_scope)].compact.join(' – '), + type: attributes[:type], + jsonpath: "$.#{column}", + displayable: true, + filterable: attributes.fetch(:filterable, true) + ) + end end end 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 86ab644f523..4df247271c3 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 @@ def columns(procedure:, displayable: true, prefix: nil) 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/app/services/api_entreprise_service.rb b/app/services/api_entreprise_service.rb index f73ccbcb01a..276efc3a747 100644 --- a/app/services/api_entreprise_service.rb +++ b/app/services/api_entreprise_service.rb @@ -22,10 +22,7 @@ def create_etablissement(dossier_or_champ, siret, user_id = nil) etablissement = dossier_or_champ.build_etablissement(etablissement_params) etablissement.save! - - if dossier_or_champ.is_a?(Champ) - dossier_or_champ.update!(value_json: APIGeoService.parse_etablissement_address(etablissement)) - end + etablissement.update_champ_value_json! perform_later_fetch_jobs(etablissement, procedure_id, user_id) @@ -49,10 +46,7 @@ def update_etablissement_from_degraded_mode(etablissement, procedure_id) return nil if etablissement_params.empty? etablissement.update!(etablissement_params) - - if etablissement.champ.present? - etablissement.champ.update!(value_json: APIGeoService.parse_etablissement_address(etablissement)) - end + etablissement.update_champ_value_json! etablissement end diff --git a/app/tasks/maintenance/populate_siret_value_json_task.rb b/app/tasks/maintenance/populate_siret_value_json_task.rb index 3b43ebb7391..4464cceca8f 100644 --- a/app/tasks/maintenance/populate_siret_value_json_task.rb +++ b/app/tasks/maintenance/populate_siret_value_json_task.rb @@ -4,15 +4,20 @@ # la normalisation des adresses des champs RNA/RNF/SIRET # le fait de stocker ces données normalisées dans le champs.value_json (un jsonb) # le backfill les anciens champs RNA/RNF/SIRET +# A (re)jouer après déploiement de PR #11013 https://github.com/demarches-simplifiees/demarches-simplifiees.fr/pull/11013 module Maintenance class PopulateSiretValueJSONTask < MaintenanceTasks::Task + include RunnableOnDeployConcern + + run_on_first_deploy + def collection Champs::SiretChamp.where.not(value: nil) end def process(champ) return if champ.etablissement.blank? - champ.update!(value_json: APIGeoService.parse_etablissement_address(champ.etablissement)) + champ.update!(value_json: champ.etablissement.champ_value_json) rescue ActiveRecord::RecordInvalid # noop, just a champ without dossier end diff --git a/app/views/shared/dossiers/_identite_entreprise.html.haml b/app/views/shared/dossiers/_identite_entreprise.html.haml index 7d2bd5dbc7d..71a128370a7 100644 --- a/app/views/shared/dossiers/_identite_entreprise.html.haml +++ b/app/views/shared/dossiers/_identite_entreprise.html.haml @@ -43,7 +43,7 @@ - c.with_value do %p= etablissement.libelle_naf - = render Dossiers::RowShowComponent.new(label: "Libellé NAF") do |c| + = render Dossiers::RowShowComponent.new(label: "Code NAF") do |c| - c.with_value do %p= etablissement.naf diff --git a/config/locales/models/procedure_presentation/en.yml b/config/locales/models/procedure_presentation/en.yml index 95ff9d0ffde..7fccc8a8eb0 100644 --- a/config/locales/models/procedure_presentation/en.yml +++ b/config/locales/models/procedure_presentation/en.yml @@ -47,13 +47,10 @@ en: question_answer: Opinion yes/no etablissement: entreprise_etat_administratif: 'Entreprise état administratif' - entreprise_forme_juridique: Forme juridique - entreprise_nom_commercial: Commercial name - entreprise_raison_sociale: Raison sociale - entreprise_siret_siege_social: SIRET siège social entreprise_date_creation: Entreprise date de création siret: Établissement SIRET libelle_naf: Libellé NAF + code_naf: Code NAF siege_social: "Établissement siège social" naf: "Établissement NAF" adresse: "Établissement Adresse" diff --git a/config/locales/models/procedure_presentation/fr.yml b/config/locales/models/procedure_presentation/fr.yml index a17cc75f8fb..9c82c0731a5 100644 --- a/config/locales/models/procedure_presentation/fr.yml +++ b/config/locales/models/procedure_presentation/fr.yml @@ -51,13 +51,10 @@ fr: question_answer: Avis oui/non etablissement: entreprise_etat_administratif: 'Entreprise état administratif' - entreprise_forme_juridique: Forme juridique - entreprise_nom_commercial: Nom commercial - entreprise_raison_sociale: Raison sociale - entreprise_siret_siege_social: SIRET siège social entreprise_date_creation: Entreprise date de création siret: Établissement SIRET libelle_naf: Libellé NAF + code_naf: Code NAF siege_social: "Établissement siège social" naf: "Établissement NAF" adresse: "Établissement Adresse" diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index b84c933795c..ed0fad2a215 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -165,7 +165,7 @@ factory :champ_do_not_use_siret, class: 'Champs::SiretChamp' do association :etablissement, factory: [:etablissement] value { '44011762001530' } - value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself) } + value_json { etablissement.champ_value_json } end factory :champ_do_not_use_rna, class: 'Champs::RNAChamp' do diff --git a/spec/models/columns/champ_column_spec.rb b/spec/models/columns/champ_column_spec.rb index 4f4ce0b0eb4..a1bf8b8b9ae 100644 --- a/spec/models/columns/champ_column_spec.rb +++ b/spec/models/columns/champ_column_spec.rb @@ -19,7 +19,21 @@ expect_type_de_champ_values('pays', eq(['France'])) expect_type_de_champ_values('epci', eq([nil])) expect_type_de_champ_values('iban', eq([nil])) - expect_type_de_champ_values('siret', eq(["44011762001530", "postal_code", "city_name", "departement_code", "region_name"])) + expect_type_de_champ_values('siret', match_array( + [ + "44011762001530", + "SA à conseil d'administration (s.a.i.)", + "440117620", + "GRTGAZ", + "GRTGAZ", + "1990-04-24", + "Transports par conduites", + "92270", + "Bois-Colombes", + "92", + "Île-de-France" + ] + )) expect_type_de_champ_values('text', eq(['text'])) expect_type_de_champ_values('textarea', eq(['textarea'])) expect_type_de_champ_values('number', eq(['42'])) diff --git a/spec/models/columns/dossier_column_spec.rb b/spec/models/columns/dossier_column_spec.rb index 46d39461ae2..8937eee72c1 100644 --- a/spec/models/columns/dossier_column_spec.rb +++ b/spec/models/columns/dossier_column_spec.rb @@ -36,9 +36,9 @@ expect(procedure.find_column(label: "Date de création").value(dossier)).to be_an_instance_of(ActiveSupport::TimeWithZone) expect(procedure.find_column(label: "Établissement SIRET").value(dossier)).to eq('44011762001530') expect(procedure.find_column(label: "Libellé NAF").value(dossier)).to eq('Transports par conduites') + expect(procedure.find_column(label: "Code NAF").value(dossier)).to eq('4950Z') expect(procedure.find_column(label: "Établissement code postal").value(dossier)).to eq('92270') expect(procedure.find_column(label: "Établissement siège social").value(dossier)).to eq(true) - expect(procedure.find_column(label: "Établissement NAF").value(dossier)).to eq('4950Z') expect(procedure.find_column(label: "Établissement Adresse").value(dossier)).to eq("GRTGAZ\r IMMEUBLE BORA\r 6 RUE RAOUL NORDLING\r 92270 BOIS COLOMBES\r") expect(procedure.find_column(label: "Établissement numero voie").value(dossier)).to eq('6') expect(procedure.find_column(label: "Établissement type voie").value(dossier)).to eq('RUE') diff --git a/spec/models/concerns/columns_concern_spec.rb b/spec/models/concerns/columns_concern_spec.rb index 3cc07308b4d..c3c185be1a7 100644 --- a/spec/models/concerns/columns_concern_spec.rb +++ b/spec/models/concerns/columns_concern_spec.rb @@ -99,9 +99,9 @@ end context 'with rna' do - let(:types_de_champ_public) { [{ type: :rna, libelle: 'rna' }] } + let(:types_de_champ_public) { [{ type: :rna, libelle: 'RNA' }] } let(:types_de_champ_private) { [] } - it { expect(subject.map(&:label)).to include('rna – commune') } + it { expect(subject.map(&:label)).to include('RNA – Commune') } end context 'with linked drop down list' do @@ -187,8 +187,8 @@ procedure.find_column(label: "France connecté ?"), procedure.find_column(label: "Établissement SIRET"), procedure.find_column(label: "Établissement siège social"), - procedure.find_column(label: "Établissement NAF"), procedure.find_column(label: "Libellé NAF"), + procedure.find_column(label: "Code NAF"), procedure.find_column(label: "Établissement Adresse"), procedure.find_column(label: "Établissement numero voie"), procedure.find_column(label: "Établissement type voie"), diff --git a/spec/models/etablissement_spec.rb b/spec/models/etablissement_spec.rb index 58e122167c4..f46c2a93bbe 100644 --- a/spec/models/etablissement_spec.rb +++ b/spec/models/etablissement_spec.rb @@ -130,6 +130,43 @@ end end + describe '#update_champ_value_json!' do + let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret }]) } + let(:dossier) { create(:dossier, procedure:) } + let(:etablissement) { create(:etablissement) } + let(:champ) { dossier.champs[0] } + let(:address_data) do + { + "street_number" => "6", + "street_name" => "RAOUL NORDLING", + "postal_code" => "92270", + "city_name" => "BOIS COLOMBES" + } + end + + before do + allow(APIGeoService).to receive(:parse_etablissement_address) + .with(etablissement) + .and_return(address_data.dup) + + etablissement.champ = champ + end + + subject(:value_json) { + etablissement.update_champ_value_json! + champ.reload.value_json + } + + it 'updates the associated champ value_json with geocoded address' do + expect(value_json).to include(address_data.stringify_keys) + end + + it 'includes jsonpathables columns entreprise attributes' do + expect(value_json["entreprise_siren"]).to eq(etablissement.siren) + expect(value_json["entreprise_raison_sociale"]).to eq(etablissement.entreprise_raison_sociale) + end + end + private def csv_to_array_of_hash(lines) diff --git a/spec/models/export_template_tabular_spec.rb b/spec/models/export_template_tabular_spec.rb index 4751ffdd255..bcaf35f763d 100644 --- a/spec/models/export_template_tabular_spec.rb +++ b/spec/models/export_template_tabular_spec.rb @@ -123,11 +123,20 @@ context 'when procedure has a TypeDeChamp::Siret' do let(:types_de_champ_public) do [ - { type: :siret, libelle: 'siret', stable_id: 20 } + { type: :siret, libelle: 'SIRET', stable_id: 20 } ] end it 'is able to resolve stable_id' do - expect(export_template.columns_for_stable_id(20).size).to eq(5) + columns = export_template.columns_for_stable_id(20) + + expect(columns.find { _1.libelle == "SIRET" }).to be_present + + %w[ + $.entreprise_nom_commercial + $.entreprise_raison_sociale + ].each do |jsonpath| + expect(columns.find { _1.column.respond_to?(:jsonpath) && _1.column.jsonpath == jsonpath }).to be_present + end end end context 'when procedure has a TypeDeChamp::Text' do 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 new file mode 100644 index 00000000000..3dc47d20d8e --- /dev/null +++ b/spec/models/types_de_champ/siret_type_de_champ_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +describe TypesDeChamp::SiretTypeDeChamp do + let(:tdc_siret) { build(:type_de_champ_siret, libelle: 'Numéro SIRET') } + let(:procedure) { build(:procedure) } + + 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", + "$.entreprise_siren" + ] + + json_columns = columns.filter { _1.is_a?(Columns::JSONPathColumn) } + expect(json_columns.map(&:jsonpath)).to include(*expected_paths) + end + + it "includes address columns" do + address_columns = columns.filter { _1.is_a?(Columns::JSONPathColumn) && _1.jsonpath.match?(/adresse|postal_code/) } + + expect(address_columns).not_to be_empty + end + + it "does not include jsonpath SIRET column" do + expect(columns.find { |c| c.is_a?(Columns::JSONPathColumn) && c.jsonpath == "$.siret" }).to be_nil + end + end +end diff --git a/spec/services/dossier_filter_service_spec.rb b/spec/services/dossier_filter_service_spec.rb index 7a85e02acef..28d16a283fe 100644 --- a/spec/services/dossier_filter_service_spec.rb +++ b/spec/services/dossier_filter_service_spec.rb @@ -572,7 +572,7 @@ def to_filter((label, filter)) = FilteredColumn.new(column: procedure.find_colum context "when searching by postal_code (text)" do let(:value) { "60580" } - let(:filter) { ["rna – code postal (5 chiffres)", value] } + let(:filter) { ["rna – Code postal (5 chiffres)", value] } before do kept_dossier.project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "postal_code" => value }) @@ -589,7 +589,7 @@ def to_filter((label, filter)) = FilteredColumn.new(column: procedure.find_colum context "when searching by departement_code (enum)" do let(:value) { "99" } - let(:filter) { ["rna – département", value] } + let(:filter) { ["rna – Département", value] } before do kept_dossier.project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "departement_code" => value }) @@ -606,7 +606,7 @@ def to_filter((label, filter)) = FilteredColumn.new(column: procedure.find_colum context "when searching by region_name" do let(:value) { "60" } - let(:filter) { ["rna – region", value] } + let(:filter) { ["rna – Région", value] } before do kept_dossier.project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "region_name" => value }) diff --git a/spec/services/dossier_projection_service_spec.rb b/spec/services/dossier_projection_service_spec.rb index e55a727348e..9029846d070 100644 --- a/spec/services/dossier_projection_service_spec.rb +++ b/spec/services/dossier_projection_service_spec.rb @@ -239,9 +239,9 @@ end context 'for a json column' do - let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret, libelle: 'siret' }]) } + let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret, libelle: 'SIRET' }]) } let(:dossier) { create(:dossier, procedure:) } - let(:label) { "siret – département" } + let(:label) { "SIRET – Département" } before do dossier.project_champs_public.first.update(value_json: { 'departement_code': '38' }) diff --git a/spec/system/instructeurs/procedure_filters_spec.rb b/spec/system/instructeurs/procedure_filters_spec.rb index 2e3f54a0edc..dac3aeaace3 100644 --- a/spec/system/instructeurs/procedure_filters_spec.rb +++ b/spec/system/instructeurs/procedure_filters_spec.rb @@ -154,7 +154,7 @@ rna_champ.reload champ_select_value = "37 – Indre-et-Loire" - add_filter("#{rna_champ.libelle} – département", champ_select_value, type: :enum) + add_filter("#{rna_champ.libelle} – Département", champ_select_value, type: :enum) expect(page).to have_link(new_unfollow_dossier.id.to_s) end end diff --git a/spec/tasks/maintenance/populate_siret_value_json_task_spec.rb b/spec/tasks/maintenance/populate_siret_value_json_task_spec.rb index f5e1a29a67b..fbc2600b44b 100644 --- a/spec/tasks/maintenance/populate_siret_value_json_task_spec.rb +++ b/spec/tasks/maintenance/populate_siret_value_json_task_spec.rb @@ -10,6 +10,10 @@ module Maintenance let(:element) { dossier.champs.first } subject(:process) { described_class.process(element) } + before do + element.update!(value_json: nil) + end + it 'updates value_json' do expect { subject }.to change { element.reload.value_json } .from(anything) @@ -25,7 +29,14 @@ module Maintenance "departement_code" => "92", "department_code" => "92", "departement_name" => "Hauts-de-Seine", - "department_name" => "Hauts-de-Seine" + "department_name" => "Hauts-de-Seine", + + "entreprise_date_creation" => "1990-04-24", + "entreprise_forme_juridique" => "SA à conseil d'administration (s.a.i.)", + "entreprise_nom_commercial" => "GRTGAZ", + "entreprise_raison_sociale" => "GRTGAZ", + "entreprise_siren" => "440117620", + "libelle_naf" => "Transports par conduites" }) end end diff --git a/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb b/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb index 9e1a722e3ef..37f5cbfa9f6 100644 --- a/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb @@ -9,9 +9,12 @@ let(:address) { AddressProxy.new(dossier.champs.first) } it 'render address' do - AddressProxy::ADDRESS_PARTS.each do |address_part| - expect(subject).to have_text(address_part) - end + expect(subject).to have_text("6 RUE RAOUL NORDLING") + expect(subject).to have_text("Bois-Colombes") + expect(subject).to have_text("92270") + expect(subject).to have_text("92009") + expect(subject).to have_text("Hauts-de-Seine – 92") + expect(subject).to have_text("Île-de-France – 11") end end