diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 4b0691c01..204311de5 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -510,12 +510,7 @@ class Procedure < ApplicationRecord procedure.parent_procedure = self procedure.canonical_procedure = nil procedure.replaced_by_procedure = nil - - if from_library - procedure.service = nil - elsif self.service.present? && is_different_admin - procedure.service = self.service.clone_and_assign_to_administrateur(admin) - end + procedure.service = nil transaction do procedure.save diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index d03fc2ad3..c81add4f6 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -525,7 +525,7 @@ describe Procedure do cloned_procedure = subject cloned_procedure.parent_procedure_id = nil - expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path", "draft_revision_id"]) + expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path", "draft_revision_id", "service_id"]) end context 'which is opendata' do @@ -569,18 +569,16 @@ describe Procedure do end end - it 'should keep service_id' do - expect(subject.service).to eq(service) + it 'should skips service_id' do + expect(subject.service).to eq(nil) end context 'when the procedure is cloned to another administrateur' do let(:administrateur) { create(:administrateur) } let(:opendata) { false } - it 'should clone service' do - expect(subject.service.id).not_to eq(service.id) - expect(subject.service.administrateur_id).not_to eq(service.administrateur_id) - expect(subject.service.attributes.except("id", "administrateur_id", "created_at", "updated_at")).to eq(service.attributes.except("id", "administrateur_id", "created_at", "updated_at")) + it 'should not clone service' do + expect(subject.service).to eq(nil) end it 'should discard old pj information' do