demarches-normaliennes/spec/controllers/champs/repetition_controller_spec.rb
simon lehericey 10a1ae5534
Revert "Merge pull request #10771 from tchak/refactor-champs-revert"
This reverts commit c902061ebf, reversing
changes made to b4ed11c788.
2024-09-19 11:09:01 +02:00

16 lines
766 B
Ruby

# frozen_string_literal: true
describe Champs::RepetitionController, type: :controller do
describe '#remove' do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :repetition, mandatory: true, children: [{ libelle: 'Nom' }, { type: :integer_number, libelle: 'Age' }] }]) }
let(:dossier) { create(:dossier, procedure: procedure) }
before { sign_in dossier.user }
it 'removes repetition' do
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 }
.to change { dossier.reload.champs.size }.from(3).to(1)
end
end
end