diff --git a/app/components/procedure/card/attestation_component.rb b/app/components/procedure/card/attestation_component.rb index 386864a6f..5cbac3dff 100644 --- a/app/components/procedure/card/attestation_component.rb +++ b/app/components/procedure/card/attestation_component.rb @@ -5,6 +5,14 @@ class Procedure::Card::AttestationComponent < ApplicationComponent private + def edit_attestation_path + if @procedure.attestation_templates_v2.any? || @procedure.feature_enabled?(:attestation_v2) + helpers.edit_admin_procedure_attestation_template_v2_path(@procedure) + else + helpers.edit_admin_procedure_attestation_template_path(@procedure) + end + end + def error_messages @procedure.errors.messages_for(:attestation_template).to_sentence end diff --git a/app/components/procedure/card/attestation_component/attestation_component.html.haml b/app/components/procedure/card/attestation_component/attestation_component.html.haml index 0b86b5997..40a68535e 100644 --- a/app/components/procedure/card/attestation_component/attestation_component.html.haml +++ b/app/components/procedure/card/attestation_component/attestation_component.html.haml @@ -1,5 +1,5 @@ .fr-col-6.fr-col-md-4.fr-col-lg-3 - = link_to edit_admin_procedure_attestation_template_path(@procedure), class: 'fr-tile fr-enlarge-link' do + = link_to edit_attestation_path, class: 'fr-tile fr-enlarge-link' do .fr-tile__body.flex.column.align-center.justify-between - if @procedure.attestation_template&.activated? %div diff --git a/spec/system/administrateurs/procedure_attestation_template_spec.rb b/spec/system/administrateurs/procedure_attestation_template_spec.rb index f2be6e451..2dde1080d 100644 --- a/spec/system/administrateurs/procedure_attestation_template_spec.rb +++ b/spec/system/administrateurs/procedure_attestation_template_spec.rb @@ -14,8 +14,14 @@ describe 'As an administrateur, I want to manage the procedure’s attestation', before { login_as(administrateur.user, scope: :user) } def find_attestation_card(with_nested_selector: nil) + attestation_path = if procedure.attestation_template&.version == 2 || procedure.feature_enabled?(:attestation_v2) + edit_admin_procedure_attestation_template_v2_path(procedure) + else + edit_admin_procedure_attestation_template_path(procedure) + end + full_selector = [ - "a[href=\"#{edit_admin_procedure_attestation_template_path(procedure)}\"]", + "a[href=\"#{attestation_path}\"]", with_nested_selector ].compact.join(" ") page.find(full_selector)