Merge pull request #4920 from tchak/keep-operation-logs-after-dossiers-removal
Keep operation logs after dossier removal
This commit is contained in:
commit
b2706b9031
3 changed files with 16 additions and 2 deletions
|
@ -38,7 +38,7 @@ class Dossier < ApplicationRecord
|
||||||
has_many :previous_followers_instructeurs, -> { distinct }, through: :previous_follows, source: :instructeur
|
has_many :previous_followers_instructeurs, -> { distinct }, through: :previous_follows, source: :instructeur
|
||||||
has_many :avis, inverse_of: :dossier, dependent: :destroy
|
has_many :avis, inverse_of: :dossier, dependent: :destroy
|
||||||
|
|
||||||
has_many :dossier_operation_logs, dependent: :destroy
|
has_many :dossier_operation_logs, dependent: :nullify
|
||||||
|
|
||||||
belongs_to :groupe_instructeur
|
belongs_to :groupe_instructeur
|
||||||
has_one :procedure, through: :groupe_instructeur
|
has_one :procedure, through: :groupe_instructeur
|
||||||
|
|
|
@ -12,8 +12,9 @@ class DossierOperationLog < ApplicationRecord
|
||||||
demander_un_avis: 'demander_un_avis'
|
demander_un_avis: 'demander_un_avis'
|
||||||
}
|
}
|
||||||
|
|
||||||
belongs_to :dossier
|
|
||||||
has_one_attached :serialized
|
has_one_attached :serialized
|
||||||
|
|
||||||
|
belongs_to :dossier, optional: true
|
||||||
belongs_to :bill_signature, optional: true
|
belongs_to :bill_signature, optional: true
|
||||||
|
|
||||||
def self.create_and_serialize(params)
|
def self.create_and_serialize(params)
|
||||||
|
|
|
@ -1131,4 +1131,17 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'dossier_operation_log after dossier deletion' do
|
||||||
|
let(:dossier) { create(:dossier) }
|
||||||
|
let(:dossier_operation_log) { create(:dossier_operation_log, dossier: dossier) }
|
||||||
|
|
||||||
|
it 'should nullify dossier link' do
|
||||||
|
expect(dossier_operation_log.dossier).to eq(dossier)
|
||||||
|
expect(DossierOperationLog.count).to eq(1)
|
||||||
|
dossier.destroy
|
||||||
|
expect(dossier_operation_log.reload.dossier).to be_nil
|
||||||
|
expect(DossierOperationLog.count).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue