Continue tests for data_with_champs method, and add a convert_specific_values_to_string for array

This commit is contained in:
JC 2016-11-14 17:25:17 +01:00
parent 5aa9c75669
commit 2f96895bb8
2 changed files with 17 additions and 8 deletions

View file

@ -297,13 +297,8 @@ class Dossier < ActiveRecord::Base
def convert_specific_values_to_string(hash_to_convert) def convert_specific_values_to_string(hash_to_convert)
hash = {} hash = {}
hash_to_convert.each do |key, value| hash_to_convert.each do |key, value|
if value.nil? value = value.to_s if !value.kind_of?(Time) && !value.nil?
value = "" hash.store(key, value)
hash.store(key, value)
else
value = value.to_s if !value.kind_of?(Time)
hash.store(key, value)
end
end end
return hash return hash
end end

View file

@ -754,7 +754,21 @@ describe Dossier do
end end
end end
describe '#export_headers' do
let(:procedure) { create(:procedure, :with_type_de_champ) }
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
subject { dossier.export_headers }
it { expect(subject).to include(:description) }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
end
describe '#data_with_champs' do describe '#data_with_champs' do
let(:procedure) { create(:procedure, :with_type_de_champ) }
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
subject { dossier.data_with_champs }
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
end end
describe '#Dossier.to_csv' do describe '#Dossier.to_csv' do
@ -803,7 +817,7 @@ describe Dossier do
let!(:procedure) { create(:procedure) } let!(:procedure) { create(:procedure) }
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
subject { Dossier.to_ods } subject { Dossier.to_xlsx }
it { expect(subject).is_a?(String) } it { expect(subject).is_a?(String) }
end end