Continue tests for data_with_champs method, and add a convert_specific_values_to_string for array
This commit is contained in:
parent
5aa9c75669
commit
2f96895bb8
2 changed files with 17 additions and 8 deletions
|
@ -297,13 +297,8 @@ class Dossier < ActiveRecord::Base
|
|||
def convert_specific_values_to_string(hash_to_convert)
|
||||
hash = {}
|
||||
hash_to_convert.each do |key, value|
|
||||
if value.nil?
|
||||
value = ""
|
||||
value = value.to_s if !value.kind_of?(Time) && !value.nil?
|
||||
hash.store(key, value)
|
||||
else
|
||||
value = value.to_s if !value.kind_of?(Time)
|
||||
hash.store(key, value)
|
||||
end
|
||||
end
|
||||
return hash
|
||||
end
|
||||
|
|
|
@ -754,7 +754,21 @@ describe Dossier do
|
|||
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
|
||||
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
|
||||
|
||||
describe '#Dossier.to_csv' do
|
||||
|
@ -803,7 +817,7 @@ describe Dossier do
|
|||
let!(:procedure) { create(: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) }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue