Skip to content

Commit

Permalink
Merge pull request #408 from etalab/bugfix/cgu-links
Browse files Browse the repository at this point in the history
Bugfix CGU links
  • Loading branch information
Isalafont authored Sep 4, 2024
2 parents be38990 + 3203a13 commit 5b06818
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
23 changes: 19 additions & 4 deletions app/form_builders/authorization_request_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ def label_value(attribute)
super
end

def wording_for(key)
I18n.t("authorization_request_forms.#{@object.form.uid.underscore}.#{key}", default: nil) ||
I18n.t("authorization_request_forms.#{@object.model_name.element}.#{key}", default: nil) ||
I18n.t("authorization_request_forms.default.#{key}", default: nil)
def wording_for(key, opts = {})
opts[:default] = nil

I18n.t("authorization_request_forms.#{@object.form.uid.underscore}.#{key}", **opts) ||
I18n.t("authorization_request_forms.#{@object.model_name.element}.#{key}", **opts) ||
I18n.t("authorization_request_forms.default.#{key}", **opts)
end

def info_for(block)
Expand Down Expand Up @@ -62,6 +64,7 @@ def cgu_check_box(opts = {})
opts[:required] = true
opts[:class] ||= []
opts[:class] << 'fr-input-group--error' if all_terms_not_accepted_error?(:terms_of_service_accepted)
opts[:label] = cgu_check_box_label

dsfr_check_box(:terms_of_service_accepted, opts)
end
Expand Down Expand Up @@ -177,4 +180,16 @@ def readonly?
def check_box_disabled
readonly?
end

private

def cgu_check_box_label
label(
:terms_of_service_accepted,
[
wording_for('terms_of_service_accepted.label', link: object.definition.cgu_link).html_safe,
required_tag,
].join(' ').html_safe
)
end
end
2 changes: 1 addition & 1 deletion app/form_builders/dsfr_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def dsfr_check_box(attribute, opts = {})
@template.safe_join(
[
check_box(attribute, class: input_classes(opts), disabled: check_box_disabled, **enhance_input_options(opts).except(:class)),
label_with_hint(attribute, opts)
opts[:label] || label_with_hint(attribute, opts)
]
)
end
Expand Down
1 change: 1 addition & 0 deletions features/habilitation_sur_une_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Fonctionnalité: Interactions sur une demande d'habilitation simple (sur une seu
Alors il y a un message d'erreur contenant "Une erreur est survenue lors de la soumission de la demande d'habilitation"
Et je suis sur la page "Démarche Certificats de Décès Électroniques Dématérialisés (CertDc)"
Et il y a un formulaire en mode résumé
Et il y a un lien vers "/cgus/20210212_dinum_hubee_cgu_v2_1_0_version_site.pdf"

Scénario: Je soumets une demande d'habilitation valide en cochant les conditions générales
Quand je démarre une nouvelle demande d'habilitation "Démarche Certificats de Décès Électroniques Dématérialisés (CertDc)"
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,7 @@
Et('je peux voir le bouton {string} grisé et désactivé') do |string|
expect(page).to have_css('button[disabled]', text: string)
end

Alors('il y a un lien vers {string}') do |url|
expect(page).to have_link(href: url)
end

0 comments on commit 5b06818

Please sign in to comment.