fix(groupe instructeur): add a dependent destroy on contact information
This commit is contained in:
parent
3b13595a41
commit
877e1f79cc
2 changed files with 16 additions and 1 deletions
|
@ -13,7 +13,7 @@ class GroupeInstructeur < ApplicationRecord
|
|||
has_and_belongs_to_many :bulk_messages, dependent: :destroy
|
||||
|
||||
has_one :defaut_procedure, -> { with_discarded }, class_name: 'Procedure', foreign_key: :defaut_groupe_instructeur_id, dependent: :nullify, inverse_of: :defaut_groupe_instructeur
|
||||
has_one :contact_information
|
||||
has_one :contact_information, dependent: :destroy
|
||||
|
||||
has_one_attached :signature
|
||||
|
||||
|
|
|
@ -129,6 +129,21 @@ describe GroupeInstructeur, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'destroy' do
|
||||
context 'with contact information' do
|
||||
let(:defaut_group) { procedure.defaut_groupe_instructeur }
|
||||
let(:second_group) { create(:groupe_instructeur, procedure:) }
|
||||
|
||||
before do
|
||||
second_group.update(contact_information: create(:contact_information))
|
||||
end
|
||||
|
||||
it 'works' do
|
||||
expect { second_group.destroy! }.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign(procedure_to_assign, instructeur_assigne: instructeur)
|
||||
|
|
Loading…
Reference in a new issue