fix(attestation): don't delete v1 published when building a v2

This commit is contained in:
Colin Darie 2024-07-02 14:10:23 +02:00
parent d609b6b71f
commit 5e25547b7b
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 2 additions and 1 deletions

View file

@ -130,7 +130,7 @@ module Administrateurs
def build_default_attestation
state = should_edit_draft? ? :draft : :published
@procedure.build_attestation_template(version: 2, json_body: AttestationTemplate::TIPTAP_BODY_DEFAULT, activated: true, state:)
@procedure.attestation_templates.build(version: 2, json_body: AttestationTemplate::TIPTAP_BODY_DEFAULT, activated: true, state:)
end
def should_edit_draft? = !@procedure.brouillon?

View file

@ -140,6 +140,7 @@ describe Administrateurs::AttestationTemplateV2sController, type: :controller do
subject
expect(assigns(:attestation_template).version).to eq(2)
expect(assigns(:attestation_template)).to be_draft
expect(attestation_template.reload).to be_present
end
end