Fix repetition data export
This commit is contained in:
parent
d1ff311879
commit
5a9468aa95
2 changed files with 15 additions and 8 deletions
|
@ -53,15 +53,17 @@ class ProcedureExportV2Service
|
|||
[dossier.champs, dossier.champs_private]
|
||||
.flatten
|
||||
.select { |champ| champ.is_a?(Champs::RepetitionChamp) }
|
||||
end
|
||||
end.group_by(&:libelle)
|
||||
end
|
||||
|
||||
def champs_repetables_options
|
||||
champs_repetables.map do |champ|
|
||||
champs_repetables.map do |libelle, champs|
|
||||
[
|
||||
champ.libelle,
|
||||
champ.rows.each_with_index.map do |champs, index|
|
||||
Champs::RepetitionChamp::Row.new(index: index + 1, dossier_id: champ.dossier_id.to_s, champs: champs)
|
||||
libelle,
|
||||
champs.flat_map do |champ|
|
||||
champ.rows.each_with_index.map do |champs, index|
|
||||
Champs::RepetitionChamp::Row.new(index: index + 1, dossier_id: champ.dossier_id.to_s, champs: champs)
|
||||
end
|
||||
end
|
||||
]
|
||||
end
|
||||
|
|
|
@ -155,8 +155,13 @@ describe ProcedureExportV2Service do
|
|||
end
|
||||
|
||||
context 'with repetitions' do
|
||||
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :for_individual, procedure: procedure) }
|
||||
let(:champ_repetition) { dossier.champs.find { |champ| champ.type_champ == 'repetition' } }
|
||||
let!(:dossiers) do
|
||||
[
|
||||
create(:dossier, :en_instruction, :with_all_champs, :for_individual, procedure: procedure),
|
||||
create(:dossier, :en_instruction, :with_all_champs, :for_individual, procedure: procedure)
|
||||
]
|
||||
end
|
||||
let(:champ_repetition) { dossiers.first.champs.find { |champ| champ.type_champ == 'repetition' } }
|
||||
|
||||
it 'should have sheets' do
|
||||
expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis', champ_repetition.libelle])
|
||||
|
@ -172,7 +177,7 @@ describe ProcedureExportV2Service do
|
|||
end
|
||||
|
||||
it 'should have data' do
|
||||
expect(repetition_sheet.data.size).to eq(2)
|
||||
expect(repetition_sheet.data.size).to eq(4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue