From 4af6957237e9070f6818fe369c252985462fe9ca Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 28 May 2024 16:22:47 +0200 Subject: [PATCH] fix(attestation): dup keep all attributes --- app/models/attestation_template.rb | 2 +- spec/models/attestation_template_spec.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb index f415e8e8b..4c542b939 100644 --- a/app/models/attestation_template.rb +++ b/app/models/attestation_template.rb @@ -96,7 +96,7 @@ class AttestationTemplate < ApplicationRecord end def dup - attestation_template = AttestationTemplate.new(title: title, body: body, footer: footer, activated: activated) + attestation_template = super ClonePiecesJustificativesService.clone_attachments(self, attestation_template) attestation_template end diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb index 638da8b4f..2807b3f64 100644 --- a/spec/models/attestation_template_spec.rb +++ b/spec/models/attestation_template_spec.rb @@ -21,9 +21,11 @@ describe AttestationTemplate, type: :model do context 'with an attestation without images' do let(:attributes) { attributes_for(:attestation_template) } - it { is_expected.to have_attributes(attributes) } - it { is_expected.to have_attributes(id: nil) } - it { expect(subject.logo.attached?).to be_falsey } + it "works" do + is_expected.to have_attributes(attributes) + is_expected.to have_attributes(id: nil) + expect(subject.logo.attached?).to be_falsey + end end context 'with an attestation with images' do