🛠️ Fix | add test to the minimal admin presence for procedure

This commit is contained in:
Thibaut Poullain 2024-10-22 16:36:50 +02:00 committed by simon lehericey
parent 5195ebd5c7
commit b969c1717f
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -210,6 +210,20 @@ describe Procedure do
it { is_expected.not_to allow_value([]).for(:administrateurs) }
end
context 'before_remove callback for minimal administrator presence' do
let(:procedure) { create(:procedure) }
it 'raises an error when trying to remove the last administrateur' do
expect(procedure.administrateurs.count).to eq(1)
expect {
procedure.administrateurs.destroy(procedure.administrateurs.first)
}.to raise_error(
ActiveRecord::RecordNotDestroyed,
"Cannot remove the last administrateur of procedure #{procedure.libelle} (#{procedure.id})"
)
end
end
context 'juridique' do
it { is_expected.not_to allow_value(nil).on(:publication).for(:cadre_juridique) }
it { is_expected.to allow_value('text').on(:publication).for(:cadre_juridique) }