Merge pull request #498 from sgmap/fix-318

[Fix #318] Add annotations privées to exported files
This commit is contained in:
gregoirenovel 2017-06-27 14:30:48 +02:00 committed by GitHub
commit e3cf1d373b
2 changed files with 15 additions and 3 deletions

View file

@ -242,6 +242,7 @@ class Dossier < ActiveRecord::Base
serialized_dossier = DossierTableExportSerializer.new(self)
data = serialized_dossier.attributes.values
data += self.champs.order('type_de_champ_id ASC').map(&:value)
data += self.champs_private.order('type_de_champ_id ASC').map(&:value)
data += self.export_entreprise_data.values
return data
end
@ -250,6 +251,7 @@ class Dossier < ActiveRecord::Base
serialized_dossier = DossierTableExportSerializer.new(self)
headers = serialized_dossier.attributes.keys
headers += self.procedure.types_de_champ.order('id ASC').map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
headers += self.procedure.types_de_champ_private.order('id ASC').map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
headers += self.export_entreprise_data.keys
return headers
end

View file

@ -486,7 +486,7 @@ describe Dossier do
end
context 'when dossier is followed' do
let(:procedure) { create(:procedure, :with_type_de_champ) }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
let(:gestionnaire) { create(:gestionnaire) }
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
let(:date1) { 1.day.ago }
@ -502,7 +502,11 @@ describe Dossier do
it { expect(subject).to include(:individual_nom) }
it { expect(subject).to include(:individual_prenom) }
it { expect(subject).to include(:individual_birthdate) }
it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
dossier.procedure.types_de_champ.count +
dossier.procedure.types_de_champ_private.count +
dossier.export_entreprise_data.count)
}
end
describe '#data_with_champs' do
@ -523,7 +527,12 @@ describe Dossier do
it { expect(subject[12]).to be_nil }
it { expect(subject[13]).to be_nil }
it { expect(subject[14]).to be_nil }
it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
it { expect(subject[15]).to be_nil }
it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
dossier.procedure.types_de_champ.count +
dossier.procedure.types_de_champ_private.count +
dossier.export_entreprise_data.count)
}
context 'dossier for individual' do
let(:dossier_with_individual) { create(:dossier, :for_individual, user: user, procedure: procedure) }
@ -556,6 +565,7 @@ describe Dossier do
nil,
nil,
nil,
nil,
"44011762001530",
"true",
"4950Z",