diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 0bef80a6c..a99204e3a 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -87,7 +87,7 @@ class Procedure < ActiveRecord::Base end def clone - procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :module_api_carto]) + procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :module_api_carto, :mail_templates]) procedure.archived = false procedure.published = false return procedure if procedure.save diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 4c67b4b9f..bd720b25a 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -164,6 +164,11 @@ describe Procedure do let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) } let!(:piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) } let!(:piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) } + + before do + procedure.mail_received.object = "Je vais ĂȘtre clonĂ©" + end + subject { procedure.clone } it 'should duplicate specific objects with different id' do @@ -171,6 +176,7 @@ describe Procedure do expect(subject).to have_same_attributes_as(procedure) expect(subject.module_api_carto).to have_same_attributes_as(procedure.module_api_carto) + subject.types_de_champ.zip(procedure.types_de_champ).each do |stc, ptc| expect(stc).to have_same_attributes_as(ptc) end @@ -178,6 +184,10 @@ describe Procedure do subject.types_de_piece_justificative.zip(procedure.types_de_piece_justificative).each do |stc, ptc| expect(stc).to have_same_attributes_as(ptc) end + + subject.mail_templates.zip(procedure.mail_templates).each do |stc, ptc| + expect(stc).to have_same_attributes_as(ptc) + end end it 'should not duplicate specific related objects' do