From 38a6b2db6379e7a3c36fd7cda1e32b939b3c6bee Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 12 Apr 2022 19:02:59 +0200 Subject: [PATCH] fix(graphql): fix AddressTypeType --- app/graphql/types/address_type.rb | 8 ++++---- app/graphql/types/personne_morale_type.rb | 2 +- spec/graphql/dossier_spec.rb | 25 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/graphql/types/address_type.rb b/app/graphql/types/address_type.rb index 86a1d8756..60f3370f3 100644 --- a/app/graphql/types/address_type.rb +++ b/app/graphql/types/address_type.rb @@ -1,10 +1,10 @@ module Types class AddressType < Types::BaseObject class AddressTypeType < Types::BaseEnum - value(:housenumber, "numéro « à la plaque »", value: :housenumber) - value(:street, "position « à la voie », placé approximativement au centre de celle-ci", value: :street) - value(:municipality, "numéro « à la commune »", value: :municipality) - value(:locality, "lieu-dit", value: :locality) + value(:housenumber, "numéro « à la plaque »", value: "housenumber") + value(:street, "position « à la voie », placé approximativement au centre de celle-ci", value: "street") + value(:municipality, "numéro « à la commune »", value: "municipality") + value(:locality, "lieu-dit", value: "locality") end field :label, String, "libellé complet de l’adresse", null: false diff --git a/app/graphql/types/personne_morale_type.rb b/app/graphql/types/personne_morale_type.rb index c8176befa..2d2d98d2b 100644 --- a/app/graphql/types/personne_morale_type.rb +++ b/app/graphql/types/personne_morale_type.rb @@ -104,7 +104,7 @@ module Types def address { label: object.adresse, - type: :housenumber, + type: "housenumber", street_number: object.numero_voie, street_name: object.nom_voie, street_address: object.nom_voie.present? ? [object.numero_voie, object.type_voie, object.nom_voie].compact.join(' ') : nil, diff --git a/spec/graphql/dossier_spec.rb b/spec/graphql/dossier_spec.rb index 7ff4cc1c3..6aba97515 100644 --- a/spec/graphql/dossier_spec.rb +++ b/spec/graphql/dossier_spec.rb @@ -31,6 +31,26 @@ RSpec.describe Types::DossierType, type: :graphql do let(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) } let(:query) { DOSSIER_WITH_CHAMPS_QUERY } let(:variables) { { number: dossier.id } } + let(:address) do + { + "type" => "housenumber", + "label" => "33 Rue Rébeval 75019 Paris", + "city_code" => "75119", + "city_name" => "Paris", + "postal_code" => "75019", + "region_code" => "11", + "region_name" => "Île-de-France", + "street_name" => "Rue Rébeval", + "street_number" => "33", + "street_address" => "33 Rue Rébeval", + "department_code" => "75", + "department_name" => "Paris" + } + end + + before do + dossier.champs.second.update(data: address) + end it { expect(data[:dossier][:champs][0][:__typename]).to eq "CommuneChamp" } it { expect(data[:dossier][:champs][1][:__typename]).to eq "AddressChamp" } @@ -86,7 +106,12 @@ RSpec.describe Types::DossierType, type: :graphql do code } fragment AddressFragment on Address { + type + label cityName + cityCode + streetName + streetNumber } GRAPHQL end