Clone mail_templates where clone procedure

This commit is contained in:
Xavier J 2016-09-01 10:43:49 +02:00
parent 7a81b18d66
commit b56883db16
2 changed files with 11 additions and 1 deletions

View file

@ -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

View file

@ -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