2023-01-19 10:38:30 +01:00
|
|
|
describe Champs::RepetitionController, type: :controller do
|
|
|
|
describe '#remove' do
|
2023-02-02 09:59:03 +01:00
|
|
|
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :repetition, mandatory: true, children: [{ libelle: 'Nom' }, { type: :integer_number, libelle: 'Age' }] }]) }
|
2023-01-19 10:38:30 +01:00
|
|
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
|
|
|
|
|
|
|
before { sign_in dossier.user }
|
|
|
|
it 'removes repetition' do
|
|
|
|
rows, repetitions = dossier.champs.partition { _1.parent_id.present? }
|
|
|
|
expect { delete :remove, params: { champ_id: repetitions.first.id, row_id: rows.first.row_id }, format: :turbo_stream }
|
|
|
|
.to change { dossier.reload.champs.size }.from(3).to(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|