groupe_instructeur: unsassign instructeurs on group destroy

Fix #4282
This commit is contained in:
Pierre de La Morinerie 2019-09-09 13:40:45 +00:00
parent f1f0c76d13
commit 2724f4667b
2 changed files with 4 additions and 4 deletions

View file

@ -2,6 +2,6 @@ class GroupeInstructeur < ApplicationRecord
DEFAULT_LABEL = 'défaut'
belongs_to :procedure
has_many :assign_tos
has_many :instructeurs, through: :assign_tos
has_many :instructeurs, through: :assign_tos, dependent: :destroy
has_many :dossiers
end

View file

@ -96,9 +96,9 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'DELETE #destroy' do
let(:procedure_draft) { create :procedure_with_dossiers, administrateur: admin, published_at: nil, archived_at: nil }
let(:procedure_published) { create :procedure_with_dossiers, administrateur: admin, aasm_state: :publiee, published_at: Time.zone.now, archived_at: nil }
let(:procedure_archived) { create :procedure_with_dossiers, administrateur: admin, aasm_state: :archivee, published_at: nil, archived_at: Time.zone.now }
let(:procedure_draft) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], published_at: nil, archived_at: nil }
let(:procedure_published) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :publiee, published_at: Time.zone.now, archived_at: nil }
let(:procedure_archived) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :archivee, published_at: nil, archived_at: Time.zone.now }
subject { delete :destroy, params: { id: procedure.id } }