Merge pull request #10573 from colinux/fix-attestation-v2-eraser

ETQ admin, ne détruit pas l'attestation v1 en allant sur la page pour préparer une v2
This commit is contained in:
Colin Darie 2024-07-02 12:35:58 +00:00 committed by GitHub
commit a4852bff3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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