Merge pull request #6629 from tchak/fix-repetition-spreadsheets
Correction de colonnes non désirées dans les démarches clonées comportant des blocs répétables (#6629)
This commit is contained in:
commit
3f52ecbd0f
2 changed files with 19 additions and 11 deletions
|
@ -297,13 +297,12 @@ class TypeDeChamp < ApplicationRecord
|
||||||
# otherwise return all types_de_champ in their latest state
|
# otherwise return all types_de_champ in their latest state
|
||||||
types_de_champ = TypeDeChamp
|
types_de_champ = TypeDeChamp
|
||||||
.fillable
|
.fillable
|
||||||
.joins(:parent)
|
.joins(parent: :revision_types_de_champ)
|
||||||
.where(parent: { stable_id: stable_id })
|
.where(parent: { stable_id: stable_id }, revision_types_de_champ: { revision_id: revision })
|
||||||
|
|
||||||
TypeDeChamp
|
TypeDeChamp
|
||||||
.where(id: types_de_champ.group(:stable_id).select('MAX(types_de_champ.id)'))
|
.where(id: types_de_champ.group(:stable_id).select('MAX(types_de_champ.id)'))
|
||||||
.joins(parent: :revision_types_de_champ)
|
.order(:order_place, id: :desc)
|
||||||
.order(:order_place, 'procedure_revision_types_de_champ.revision_id': :desc)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -342,6 +342,14 @@ describe ProcedureExportService do
|
||||||
expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis', champ_repetition.libelle_for_export])
|
expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis', champ_repetition.libelle_for_export])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with cloned procedure' do
|
||||||
|
let(:other_parent) { create(:type_de_champ_repetition, stable_id: champ_repetition.stable_id) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
create(:procedure_revision_type_de_champ, type_de_champ: other_parent, revision: create(:procedure).active_revision)
|
||||||
|
create(:type_de_champ, parent: other_parent)
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have headers' do
|
it 'should have headers' do
|
||||||
expect(repetition_sheet.headers).to eq([
|
expect(repetition_sheet.headers).to eq([
|
||||||
"Dossier ID",
|
"Dossier ID",
|
||||||
|
@ -350,6 +358,7 @@ describe ProcedureExportService do
|
||||||
"Age"
|
"Age"
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have data' do
|
it 'should have data' do
|
||||||
expect(repetition_sheet.data.size).to eq(4)
|
expect(repetition_sheet.data.size).to eq(4)
|
||||||
|
|
Loading…
Add table
Reference in a new issue