fix(attestation): dup keep all attributes

This commit is contained in:
Colin Darie 2024-05-28 16:22:47 +02:00
parent c5c24c01d8
commit 4af6957237
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 6 additions and 4 deletions

View file

@ -96,7 +96,7 @@ class AttestationTemplate < ApplicationRecord
end end
def dup def dup
attestation_template = AttestationTemplate.new(title: title, body: body, footer: footer, activated: activated) attestation_template = super
ClonePiecesJustificativesService.clone_attachments(self, attestation_template) ClonePiecesJustificativesService.clone_attachments(self, attestation_template)
attestation_template attestation_template
end end

View file

@ -21,9 +21,11 @@ describe AttestationTemplate, type: :model do
context 'with an attestation without images' do context 'with an attestation without images' do
let(:attributes) { attributes_for(:attestation_template) } let(:attributes) { attributes_for(:attestation_template) }
it { is_expected.to have_attributes(attributes) } it "works" do
it { is_expected.to have_attributes(id: nil) } is_expected.to have_attributes(attributes)
it { expect(subject.logo.attached?).to be_falsey } is_expected.to have_attributes(id: nil)
expect(subject.logo.attached?).to be_falsey
end
end end
context 'with an attestation with images' do context 'with an attestation with images' do