Change Dossier#convert_specific_array_values_to_string’s signature and name

- It is always called with the data_with_champs
  argument

- Changing the signature requires a change of name
  in this case
This commit is contained in:
gregoirenovel 2017-04-05 15:10:58 +02:00
parent 64fdc7a2af
commit df878b9ef4
3 changed files with 49 additions and 3 deletions

View file

@ -216,9 +216,9 @@ class Dossier < ActiveRecord::Base
return hash
end
def convert_specific_array_values_to_string(array_to_convert)
def full_data_strings_array
array = []
array_to_convert.each do |value|
data_with_champs.each do |value|
value = value.to_s if !value.kind_of?(Time) && !value.nil?
array << value
end

View file

@ -135,7 +135,7 @@ class Procedure < ActiveRecord::Base
headers = exportable_dossiers.any? ? exportable_dossiers.first.export_headers : []
data = exportable_dossiers.map do |dossier|
dossier.convert_specific_array_values_to_string(dossier.data_with_champs)
dossier.full_data_strings_array
end
{

View file

@ -616,6 +616,52 @@ describe Dossier do
it { expect(subject[9]).to eq(dossier.followers_gestionnaires_emails) }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
end
describe "#full_data_string" do
let(:expected_string) {
[
dossier.id.to_s,
dossier.created_at,
dossier.updated_at,
"false",
"false",
"draft",
dossier.initiated_at,
dossier.received_at,
dossier.processed_at,
gestionnaire.email,
nil,
"44011762001530",
"true",
"4950Z",
"Transports par conduites",
"GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES",
"6",
"RUE",
"RAOUL NORDLING",
"IMMEUBLE BORA",
"92270",
"BOIS COLOMBES",
"92009",
"440117620",
"537100000",
"FR27440117620",
"SA à conseil d'administration (s.a.i.)",
"5599",
"GRTGAZ",
"GRTGAZ",
"44011762001530",
"51",
dossier.entreprise.date_creation,
nil,
nil
]
}
subject { dossier }
it { expect(dossier.full_data_strings_array).to eq(expected_string)}
end
end
describe '#Dossier.to_csv' do