diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 559f621b8..7673b15cc 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -298,10 +298,8 @@ class TypeDeChamp < ApplicationRecord TypeDeChamp.type_champs.fetch(:repetition), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list), TypeDeChamp.type_champs.fetch(:epci), - TypeDeChamp.type_champs.fetch(:annuaire_education), TypeDeChamp.type_champs.fetch(:dossier_link), - TypeDeChamp.type_champs.fetch(:siret), - TypeDeChamp.type_champs.fetch(:rna) + TypeDeChamp.type_champs.fetch(:siret) ]) end diff --git a/app/models/types_de_champ/prefill_annuaire_education_type_de_champ.rb b/app/models/types_de_champ/prefill_annuaire_education_type_de_champ.rb deleted file mode 100644 index 7790458d9..000000000 --- a/app/models/types_de_champ/prefill_annuaire_education_type_de_champ.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class TypesDeChamp::PrefillAnnuaireEducationTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp - def to_assignable_attributes(champ, value) - return nil if value.blank? - - { - id: champ.id, - external_id: value, - value: value - } - end -end diff --git a/app/models/types_de_champ/prefill_type_de_champ.rb b/app/models/types_de_champ/prefill_type_de_champ.rb index 46917ea62..1b112f094 100644 --- a/app/models/types_de_champ/prefill_type_de_champ.rb +++ b/app/models/types_de_champ/prefill_type_de_champ.rb @@ -31,8 +31,6 @@ class TypesDeChamp::PrefillTypeDeChamp < SimpleDelegator TypesDeChamp::PrefillAddressTypeDeChamp.new(type_de_champ, revision) when TypeDeChamp.type_champs.fetch(:epci) TypesDeChamp::PrefillEpciTypeDeChamp.new(type_de_champ, revision) - when TypeDeChamp.type_champs.fetch(:annuaire_education) - TypesDeChamp::PrefillAnnuaireEducationTypeDeChamp.new(type_de_champ, revision) else new(type_de_champ, revision) end diff --git a/spec/models/prefill_champs_spec.rb b/spec/models/prefill_champs_spec.rb index 14a31b117..fc6e5d4a4 100644 --- a/spec/models/prefill_champs_spec.rb +++ b/spec/models/prefill_champs_spec.rb @@ -124,12 +124,10 @@ RSpec.describe PrefillChamps do it_behaves_like "a champ public value that is authorized", :departements, "03" it_behaves_like "a champ public value that is authorized", :communes, ['01540', '01457'] it_behaves_like "a champ public value that is authorized", :address, "20 avenue de Ségur 75007 Paris" - it_behaves_like "a champ public value that is authorized", :annuaire_education, "0050009H" it_behaves_like "a champ public value that is authorized", :multiple_drop_down_list, ["val1", "val2"] it_behaves_like "a champ public value that is authorized", :dossier_link, "1" it_behaves_like "a champ public value that is authorized", :epci, ['01', '200042935'] it_behaves_like "a champ public value that is authorized", :siret, "13002526500013" - it_behaves_like "a champ public value that is authorized", :rna, "value" context "when the public type de champ is authorized (repetition)" do let(:types_de_champ_public) { [{ type: :repetition, children: [{ type: :text }] }] } @@ -164,12 +162,10 @@ RSpec.describe PrefillChamps do it_behaves_like "a champ private value that is authorized", :checkbox, "false" it_behaves_like "a champ private value that is authorized", :drop_down_list, "value" it_behaves_like "a champ private value that is authorized", :regions, "93" - it_behaves_like "a champ private value that is authorized", :rna, "value" it_behaves_like "a champ private value that is authorized", :siret, "13002526500013" it_behaves_like "a champ private value that is authorized", :departements, "03" it_behaves_like "a champ private value that is authorized", :communes, ['01540', '01457'] it_behaves_like "a champ private value that is authorized", :address, "20 avenue de Ségur 75007 Paris" - it_behaves_like "a champ private value that is authorized", :annuaire_education, "0050009H" it_behaves_like "a champ private value that is authorized", :multiple_drop_down_list, ["val1", "val2"] it_behaves_like "a champ private value that is authorized", :dossier_link, "1" it_behaves_like "a champ private value that is authorized", :epci, ['01', '200042935'] diff --git a/spec/models/type_de_champ_spec.rb b/spec/models/type_de_champ_spec.rb index 94e5ad974..4f766ba14 100644 --- a/spec/models/type_de_champ_spec.rb +++ b/spec/models/type_de_champ_spec.rb @@ -255,12 +255,10 @@ describe TypeDeChamp do it_behaves_like "a prefillable type de champ", :type_de_champ_checkbox it_behaves_like "a prefillable type de champ", :type_de_champ_drop_down_list it_behaves_like "a prefillable type de champ", :type_de_champ_repetition - it_behaves_like "a prefillable type de champ", :type_de_champ_annuaire_education it_behaves_like "a prefillable type de champ", :type_de_champ_multiple_drop_down_list it_behaves_like "a prefillable type de champ", :type_de_champ_epci it_behaves_like "a prefillable type de champ", :type_de_champ_dossier_link it_behaves_like "a prefillable type de champ", :type_de_champ_siret - it_behaves_like "a prefillable type de champ", :type_de_champ_rna it_behaves_like "a non-prefillable type de champ", :type_de_champ_number it_behaves_like "a non-prefillable type de champ", :type_de_champ_titre_identite @@ -273,6 +271,8 @@ describe TypeDeChamp do it_behaves_like "a non-prefillable type de champ", :type_de_champ_pole_emploi it_behaves_like "a non-prefillable type de champ", :type_de_champ_mesri it_behaves_like "a non-prefillable type de champ", :type_de_champ_carte + it_behaves_like "a non-prefillable type de champ", :type_de_champ_rna + it_behaves_like "a non-prefillable type de champ", :type_de_champ_annuaire_education end describe '#normalize_libelle' do diff --git a/spec/models/types_de_champ/prefill_annuaire_education_type_de_champ_spec.rb b/spec/models/types_de_champ/prefill_annuaire_education_type_de_champ_spec.rb deleted file mode 100644 index 6e3b80325..000000000 --- a/spec/models/types_de_champ/prefill_annuaire_education_type_de_champ_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe TypesDeChamp::PrefillAnnuaireEducationTypeDeChamp do - let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :annuaire_education }]) } - let(:dossier) { create(:dossier, procedure:) } - let(:type_de_champ) { procedure.active_revision.types_de_champ.first } - - describe 'ancestors' do - subject { described_class.new(type_de_champ, procedure.active_revision) } - - it { is_expected.to be_kind_of(TypesDeChamp::PrefillTypeDeChamp) } - end - - describe '#to_assignable_attributes' do - let(:champ) { dossier.champs.first } - subject { described_class.build(type_de_champ, procedure.active_revision).to_assignable_attributes(champ, value) } - - context 'when the value is nil' do - let(:value) { nil } - it { is_expected.to eq(nil) } - end - - context 'when the value is empty' do - let(:value) { '' } - it { is_expected.to eq(nil) } - end - - context 'when the value is present' do - let(:value) { '0050009H' } - it { is_expected.to match({ id: champ.id, external_id: '0050009H', value: '0050009H' }) } - end - end -end diff --git a/spec/models/types_de_champ/prefill_type_de_champ_spec.rb b/spec/models/types_de_champ/prefill_type_de_champ_spec.rb index 38577f90d..35955a466 100644 --- a/spec/models/types_de_champ/prefill_type_de_champ_spec.rb +++ b/spec/models/types_de_champ/prefill_type_de_champ_spec.rb @@ -63,12 +63,6 @@ RSpec.describe TypesDeChamp::PrefillTypeDeChamp, type: :model do it { expect(built).to be_kind_of(TypesDeChamp::PrefillEpciTypeDeChamp) } end - context 'when the type de champ is an annuaire_education' do - let(:type_de_champ) { build(:type_de_champ_annuaire_education) } - - it { expect(built).to be_kind_of(TypesDeChamp::PrefillAnnuaireEducationTypeDeChamp) } - end - context 'when any other type de champ' do let(:type_de_champ) { build(:type_de_champ_date, procedure: procedure) } diff --git a/spec/support/shared_examples_for_prefilled_dossier.rb b/spec/support/shared_examples_for_prefilled_dossier.rb index 841a20c14..721eeb877 100644 --- a/spec/support/shared_examples_for_prefilled_dossier.rb +++ b/spec/support/shared_examples_for_prefilled_dossier.rb @@ -18,7 +18,6 @@ shared_examples "the user has got a prefilled dossier, owned by themselves" do expect(page).to have_field(type_de_champ_text.libelle, with: text_value) expect(page).to have_field(type_de_champ_phone.libelle, with: phone_value) expect(page).to have_css('label', text: type_de_champ_phone.libelle) - expect(page).to have_field(type_de_champ_rna.libelle, with: rna_value) expect(page).to have_field(type_de_champ_siret.libelle, with: siret_value) expect(page).to have_css('legend', text: type_de_champ_repetition.libelle) expect(page).to have_field(text_repetition_libelle, with: text_repetition_value) @@ -31,7 +30,6 @@ shared_examples "the user has got a prefilled dossier, owned by themselves" do expect(page).to have_selector("option[value='#{epci_value.last}'][selected]") expect(page).to have_field(type_de_champ_dossier_link.libelle, with: dossier_link_value) expect(page).to have_field(type_de_champ_commune.libelle, with: commune_libelle) - expect(page).to have_content(annuaire_education_value.last) expect(page).to have_content(address_value.last) end end diff --git a/spec/system/users/dossier_prefill_get_spec.rb b/spec/system/users/dossier_prefill_get_spec.rb index 616e282b0..b6271fd8c 100644 --- a/spec/system/users/dossier_prefill_get_spec.rb +++ b/spec/system/users/dossier_prefill_get_spec.rb @@ -7,12 +7,10 @@ describe 'Prefilling a dossier (with a GET request):', js: true do [ { type: :text }, { type: :phone }, - { type: :rna }, { type: :siret }, { type: :datetime }, { type: :multiple_drop_down_list }, { type: :epci }, - { type: :annuaire_education }, { type: :dossier_link }, { type: :communes }, { type: :address }, @@ -25,20 +23,17 @@ describe 'Prefilling a dossier (with a GET request):', js: true do let(:type_de_champ_text) { types_de_champ[0] } let(:type_de_champ_phone) { types_de_champ[1] } - let(:type_de_champ_rna) { types_de_champ[2] } - let(:type_de_champ_siret) { types_de_champ[3] } - let(:type_de_champ_datetime) { types_de_champ[4] } - let(:type_de_champ_multiple_drop_down_list) { types_de_champ[5] } - let(:type_de_champ_epci) { types_de_champ[6] } - let(:type_de_champ_annuaire_education) { types_de_champ[7] } - let(:type_de_champ_dossier_link) { types_de_champ[8] } - let(:type_de_champ_commune) { types_de_champ[9] } - let(:type_de_champ_address) { types_de_champ[10] } - let(:type_de_champ_repetition) { types_de_champ[11] } + let(:type_de_champ_siret) { types_de_champ[2] } + let(:type_de_champ_datetime) { types_de_champ[3] } + let(:type_de_champ_multiple_drop_down_list) { types_de_champ[4] } + let(:type_de_champ_epci) { types_de_champ[5] } + let(:type_de_champ_dossier_link) { types_de_champ[6] } + let(:type_de_champ_commune) { types_de_champ[7] } + let(:type_de_champ_address) { types_de_champ[8] } + let(:type_de_champ_repetition) { types_de_champ[9] } let(:text_value) { "My Neighbor Totoro is the best movie ever" } let(:phone_value) { "invalid phone value" } - let(:rna_value) { 'W595001988' } let(:siret_value) { '41816609600051' } let(:datetime_value) { "2023-02-01T10:32" } let(:multiple_drop_down_list_values) { @@ -57,7 +52,6 @@ describe 'Prefilling a dossier (with a GET request):', js: true do let(:integer_repetition_libelle) { sub_types_de_champ_repetition.second.libelle } let(:text_repetition_value) { "First repetition text" } let(:integer_repetition_value) { "42" } - let(:annuaire_education_value) { '0050009H' } let(:prenom_value) { 'Jean' } let(:nom_value) { 'Dupont' } let(:genre_value) { 'M.' } @@ -74,14 +68,12 @@ describe 'Prefilling a dossier (with a GET request):', js: true do "champ_#{type_de_champ_commune.to_typed_id_for_query}" => commune_value, "champ_#{type_de_champ_address.to_typed_id_for_query}" => address_value, "champ_#{type_de_champ_siret.to_typed_id_for_query}" => siret_value, - "champ_#{type_de_champ_rna.to_typed_id_for_query}" => rna_value, "champ_#{type_de_champ_repetition.to_typed_id_for_query}" => [ { "champ_#{sub_types_de_champ_repetition.first.to_typed_id_for_query}": text_repetition_value, "champ_#{sub_types_de_champ_repetition.second.to_typed_id_for_query}": integer_repetition_value } ], - "champ_#{type_de_champ_annuaire_education.to_typed_id_for_query}" => annuaire_education_value, "identite_prenom" => prenom_value, "identite_nom" => nom_value, "identite_genre" => genre_value @@ -94,9 +86,6 @@ describe 'Prefilling a dossier (with a GET request):', js: true do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/insee\/sirene\/unites_legales\/#{siret_value[0..8]}/) .to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/entreprises.json')) - - stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/djepva\/api-association\/associations\/open_data\/#{rna_value}/) - .to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json')) end context 'when authenticated' do diff --git a/spec/system/users/dossier_prefill_post_spec.rb b/spec/system/users/dossier_prefill_post_spec.rb index 55d0f99da..1614a3f63 100644 --- a/spec/system/users/dossier_prefill_post_spec.rb +++ b/spec/system/users/dossier_prefill_post_spec.rb @@ -7,12 +7,10 @@ describe 'Prefilling a dossier (with a POST request):', js: true do [ { type: :text }, { type: :phone }, - { type: :rna }, { type: :siret }, { type: :datetime }, { type: :multiple_drop_down_list }, { type: :epci }, - { type: :annuaire_education }, { type: :dossier_link }, { type: :communes }, { type: :address }, @@ -25,20 +23,17 @@ describe 'Prefilling a dossier (with a POST request):', js: true do let(:type_de_champ_text) { types_de_champ[0] } let(:type_de_champ_phone) { types_de_champ[1] } - let(:type_de_champ_rna) { types_de_champ[2] } - let(:type_de_champ_siret) { types_de_champ[3] } - let(:type_de_champ_datetime) { types_de_champ[4] } - let(:type_de_champ_multiple_drop_down_list) { types_de_champ[5] } - let(:type_de_champ_epci) { types_de_champ[6] } - let(:type_de_champ_annuaire_education) { types_de_champ[7] } - let(:type_de_champ_dossier_link) { types_de_champ[8] } - let(:type_de_champ_commune) { types_de_champ[9] } - let(:type_de_champ_address) { types_de_champ[10] } - let(:type_de_champ_repetition) { types_de_champ[11] } + let(:type_de_champ_siret) { types_de_champ[2] } + let(:type_de_champ_datetime) { types_de_champ[3] } + let(:type_de_champ_multiple_drop_down_list) { types_de_champ[4] } + let(:type_de_champ_epci) { types_de_champ[5] } + let(:type_de_champ_dossier_link) { types_de_champ[6] } + let(:type_de_champ_commune) { types_de_champ[7] } + let(:type_de_champ_address) { types_de_champ[8] } + let(:type_de_champ_repetition) { types_de_champ[9] } let(:text_value) { "My Neighbor Totoro is the best movie ever" } let(:phone_value) { "invalid phone value" } - let(:rna_value) { 'W595001988' } let(:siret_value) { '41816609600051' } let(:datetime_value) { "2023-02-01T10:32" } let(:multiple_drop_down_list_values) { @@ -57,7 +52,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do let(:text_repetition_value) { "First repetition text" } let(:integer_repetition_value) { "42" } let(:dossier_link_value) { '42' } - let(:annuaire_education_value) { '0050009H' } let(:prenom_value) { 'Jean' } let(:nom_value) { 'Dupont' } let(:genre_value) { 'M.' } @@ -68,9 +62,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/insee\/sirene\/unites_legales\/#{siret_value[0..8]}/) .to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/entreprises.json')) - - stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/djepva\/api-association\/associations\/open_data\/#{rna_value}/) - .to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json')) end scenario "the user get the URL of a prefilled orphan brouillon dossier" do @@ -166,7 +157,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do params: { "champ_#{type_de_champ_text.to_typed_id_for_query}" => text_value, "champ_#{type_de_champ_phone.to_typed_id_for_query}" => phone_value, - "champ_#{type_de_champ_rna.to_typed_id_for_query}" => rna_value, "champ_#{type_de_champ_siret.to_typed_id_for_query}" => siret_value, "champ_#{type_de_champ_repetition.to_typed_id_for_query}" => [ { @@ -180,7 +170,6 @@ describe 'Prefilling a dossier (with a POST request):', js: true do "champ_#{type_de_champ_dossier_link.to_typed_id_for_query}" => dossier_link_value, "champ_#{type_de_champ_commune.to_typed_id_for_query}" => commune_value, "champ_#{type_de_champ_address.to_typed_id_for_query}" => address_value, - "champ_#{type_de_champ_annuaire_education.to_typed_id_for_query}" => annuaire_education_value, "identite_prenom" => prenom_value, "identite_nom" => nom_value, "identite_genre" => genre_value