Remove carriage returns in address in CSV format only
This commit is contained in:
parent
63cf35a748
commit
f62c9ebec9
4 changed files with 7 additions and 5 deletions
|
@ -190,7 +190,7 @@ class Dossier < ActiveRecord::Base
|
||||||
|
|
||||||
def as_csv(options={})
|
def as_csv(options={})
|
||||||
dossier_attr = DossierSerializer.new(self).attributes
|
dossier_attr = DossierSerializer.new(self).attributes
|
||||||
etablissement_attr = EtablissementSerializer.new(self.etablissement).attributes.map {|k, v| ["etablissement.#{k}", v] }.to_h
|
etablissement_attr = EtablissementCsvSerializer.new(self.etablissement).attributes.map {|k, v| ["etablissement.#{k}", v] }.to_h
|
||||||
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map {|k, v| ["entreprise.#{k}", v] }.to_h
|
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map {|k, v| ["entreprise.#{k}", v] }.to_h
|
||||||
dossier_attr.merge(etablissement_attr).merge(entreprise_attr)
|
dossier_attr.merge(etablissement_attr).merge(entreprise_attr)
|
||||||
end
|
end
|
||||||
|
|
5
app/serializers/etablissement_csv_serializer.rb
Normal file
5
app/serializers/etablissement_csv_serializer.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class EtablissementCsvSerializer < EtablissementSerializer
|
||||||
|
def adresse
|
||||||
|
object.adresse.chomp.gsub("\r\n", ' ').gsub("\r", '')
|
||||||
|
end
|
||||||
|
end
|
|
@ -12,7 +12,4 @@ class EtablissementSerializer < ActiveModel::Serializer
|
||||||
:localite,
|
:localite,
|
||||||
:code_insee_localite
|
:code_insee_localite
|
||||||
|
|
||||||
def adresse
|
|
||||||
object.adresse.chomp.gsub("\r\n", ' ')
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -538,7 +538,7 @@ describe Dossier do
|
||||||
it { expect(subject['etablissement.siege_social']).to be_truthy }
|
it { expect(subject['etablissement.siege_social']).to be_truthy }
|
||||||
it { expect(subject['etablissement.naf']).to eq('4950Z') }
|
it { expect(subject['etablissement.naf']).to eq('4950Z') }
|
||||||
it { expect(subject['etablissement.libelle_naf']).to eq('Transports par conduites') }
|
it { expect(subject['etablissement.libelle_naf']).to eq('Transports par conduites') }
|
||||||
it { expect(subject['etablissement.adresse']).to eq("GRTGAZ\r IMMEUBLE BORA\r 6 RUE RAOUL NORDLING\r 92270 BOIS COLOMBES\r") }
|
it { expect(subject['etablissement.adresse']).to eq("GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES") }
|
||||||
it { expect(subject['etablissement.numero_voie']).to eq('6') }
|
it { expect(subject['etablissement.numero_voie']).to eq('6') }
|
||||||
it { expect(subject['etablissement.type_voie']).to eq('RUE') }
|
it { expect(subject['etablissement.type_voie']).to eq('RUE') }
|
||||||
it { expect(subject['etablissement.nom_voie']).to eq('RAOUL NORDLING') }
|
it { expect(subject['etablissement.nom_voie']).to eq('RAOUL NORDLING') }
|
||||||
|
|
Loading…
Reference in a new issue