Use map when possible

This commit is contained in:
gregoirenovel 2018-01-30 15:16:02 +01:00
parent 5b62bc4f12
commit c9a79b4f08
2 changed files with 4 additions and 8 deletions

View file

@ -32,13 +32,9 @@ class SIADE::EtablissementAdapter
end
def adresse
adresse = ''
[:l1, :l2, :l3, :l4, :l5, :l6, :l7].each do |line|
if data_source[:etablissement][:adresse][line].present?
adresse = adresse + data_source[:etablissement][:adresse][line] + "\r\n"
end
end
adresse
[:l1, :l2, :l3, :l4, :l5, :l6, :l7].map do |line|
data_source[:etablissement][:adresse][line]
end.compact.join("\r\n")
end
def address_attribut_to_fetch

View file

@ -33,7 +33,7 @@ describe SIADE::EtablissementAdapter do
context 'Concaténation lignes adresse' do
it 'L\'entreprise contient bien une adresse sur plusieurs lignes' do
expect(subject[:adresse]).to eq("OCTO TECHNOLOGY\r\n50 AVENUE DES CHAMPS ELYSEES\r\n75008 PARIS\r\nFRANCE\r\n")
expect(subject[:adresse]).to eq("OCTO TECHNOLOGY\r\n50 AVENUE DES CHAMPS ELYSEES\r\n75008 PARIS\r\nFRANCE")
end
end