Fix bug clonage private fields

This commit is contained in:
Xavier J 2016-09-09 17:39:56 +02:00
parent f6ab83f8bd
commit 969e5f020a
2 changed files with 11 additions and 1 deletions

View file

@ -89,7 +89,7 @@ class Procedure < ActiveRecord::Base
end end
def clone def clone
procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :module_api_carto, :mail_templates]) procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :types_de_champ_private, :module_api_carto, :mail_templates])
procedure.archived = false procedure.archived = false
procedure.published = false procedure.published = false
procedure.logo_secure_token = nil procedure.logo_secure_token = nil

View file

@ -163,6 +163,8 @@ describe Procedure do
let(:procedure) { create(:procedure, archived: archived, published: published) } let(:procedure) { create(:procedure, archived: archived, published: published) }
let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) } let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) } let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) }
let!(:type_de_champ_private_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) }
let!(:type_de_champ_private_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) }
let!(:piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) } 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) } let!(:piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
@ -177,11 +179,19 @@ describe Procedure do
expect(subject).to have_same_attributes_as(procedure) expect(subject).to have_same_attributes_as(procedure)
expect(subject.module_api_carto).to have_same_attributes_as(procedure.module_api_carto) expect(subject.module_api_carto).to have_same_attributes_as(procedure.module_api_carto)
expect(subject.types_de_piece_justificative.size).to eq procedure.types_de_piece_justificative.size
expect(subject.types_de_champ.size).to eq procedure.types_de_champ.size
expect(subject.types_de_champ_private.size).to eq procedure.types_de_champ_private.size
expect(subject.mail_templates.size).to eq procedure.mail_templates.size
subject.types_de_champ.zip(procedure.types_de_champ).each do |stc, ptc| subject.types_de_champ.zip(procedure.types_de_champ).each do |stc, ptc|
expect(stc).to have_same_attributes_as(ptc) expect(stc).to have_same_attributes_as(ptc)
end end
subject.types_de_champ_private.zip(procedure.types_de_champ_private).each do |stc, ptc|
expect(stc).to have_same_attributes_as(ptc)
end
subject.types_de_piece_justificative.zip(procedure.types_de_piece_justificative).each do |stc, ptc| subject.types_de_piece_justificative.zip(procedure.types_de_piece_justificative).each do |stc, ptc|
expect(stc).to have_same_attributes_as(ptc) expect(stc).to have_same_attributes_as(ptc)
end end