2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2024-04-15 15:06:05 +02:00
|
|
|
rows, repetitions = dossier.champs.partition(&:child?)
|
|
|
|
repetition = repetitions.first
|
|
|
|
expect { delete :remove, params: { dossier_id: repetition.dossier, stable_id: repetition.stable_id, row_id: rows.first.row_id }, format: :turbo_stream }
|
2023-01-19 10:38:30 +01:00
|
|
|
.to change { dossier.reload.champs.size }.from(3).to(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|