diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 6171d5791..a27e57b47 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -295,6 +295,7 @@ class Procedure < ApplicationRecord procedure.cloned_from_library = from_library procedure.parent_procedure = self + procedure.canonical_procedure = nil if from_library procedure.service = nil diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 3b7a9b26c..080d753a5 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -538,6 +538,15 @@ describe Procedure do expect(subject.deliberation.attached?).to be true end end + + context 'with canonical procedure' do + let(:canonical_procedure) { create(:procedure) } + let(:procedure) { create(:procedure, canonical_procedure: canonical_procedure, received_mail: received_mail, service: service) } + + it 'do not clone canonical procedure' do + expect(subject.canonical_procedure).to be_nil + end + end end describe '#publish!' do