Merge pull request #7151 from tchak/fix-graphql-addresse
fix(graphql): fix AddressTypeType
This commit is contained in:
commit
e3a9c28b6e
3 changed files with 30 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue