chore(attestation): card link to v2 if exist

This commit is contained in:
Colin Darie 2024-05-29 21:47:09 +02:00
parent 151b3f83ed
commit ffd8c5617a
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
3 changed files with 16 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -14,8 +14,14 @@ describe 'As an administrateur, I want to manage the procedures 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)