diff --git a/app/presenters/completions_presenter.rb b/app/presenters/completions_presenter.rb index e83a3bb37f3..8e5b831624b 100644 --- a/app/presenters/completions_presenter.rb +++ b/app/presenters/completions_presenter.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true class CompletionsPresenter + include ActionView::Helpers::TranslationHelper + include ActionView::Helpers::TagHelper + attr_reader :current_user, :current_sp, :decrypted_pii, :requested_attributes, :completion_context SORTED_IAL2_ATTRIBUTE_MAPPING = [ @@ -72,33 +75,24 @@ def heading end def intro - if ial2_requested? - if consent_has_expired? - I18n.t( - 'help_text.requested_attributes.ial2_consent_reminder_html', - sp: sp_name, - ) - elsif reverified_after_consent? - I18n.t( - 'help_text.requested_attributes.ial2_reverified_consent_info', - sp: sp_name, - ) - else - I18n.t( - 'help_text.requested_attributes.ial2_intro_html', - sp: sp_name, - ) - end - elsif consent_has_expired? - I18n.t( - 'help_text.requested_attributes.ial1_consent_reminder_html', - sp: sp_name, + if consent_has_expired? + safe_join( + [ + t( + 'help_text.requested_attributes.consent_reminder_html', + sp_html: content_tag(:strong, sp_name), + ), + t('help_text.requested_attributes.intro_html', sp_html: content_tag(:strong, sp_name)), + ], + ' ', ) - else - I18n.t( - 'help_text.requested_attributes.ial1_intro_html', - sp: sp_name, + elsif ial2_requested? && reverified_after_consent? + t( + 'help_text.requested_attributes.ial2_reverified_consent_info_html', + sp_html: content_tag(:strong, sp_name), ) + else + t('help_text.requested_attributes.intro_html', sp_html: content_tag(:strong, sp_name)) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index f1a3b37a92f..1e46caae24f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -958,13 +958,11 @@ headings.webauthn_setup.new: Insert your security key help_text.requested_attributes.address: Address help_text.requested_attributes.all_emails: Email addresses on your account help_text.requested_attributes.birthdate: Date of birth +help_text.requested_attributes.consent_reminder_html: You must consent each year to share your information with %{sp_html}. help_text.requested_attributes.email: Email address help_text.requested_attributes.full_name: Full name -help_text.requested_attributes.ial1_consent_reminder_html: You must consent each year to share your information with %{sp}. We’ll share your information with %{sp} to connect your account. -help_text.requested_attributes.ial1_intro_html: We’ll share your information with %{sp} to connect your account. -help_text.requested_attributes.ial2_consent_reminder_html: '%{sp} needs to know who you are to connect to your account. You must consent each year to share your verified information with %{sp}. We’ll share this information:' -help_text.requested_attributes.ial2_intro_html: '%{sp} needs to know who you are to connect your account. We’ll share this information with %{sp}:' -help_text.requested_attributes.ial2_reverified_consent_info: 'Because you verified your identity again, we need your permission to share this information with %{sp}:' +help_text.requested_attributes.ial2_reverified_consent_info_html: 'Because you verified your identity again, we need your permission to share this information with %{sp_html}:' +help_text.requested_attributes.intro_html: 'We’ll share this information with %{sp_html}:' help_text.requested_attributes.phone: Phone number help_text.requested_attributes.social_security_number: Social Security number help_text.requested_attributes.verified_at: Updated on diff --git a/config/locales/es.yml b/config/locales/es.yml index 2d5bcae878a..b6807a59895 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -969,13 +969,11 @@ headings.webauthn_setup.new: Inserte su clave de seguridad help_text.requested_attributes.address: Dirección help_text.requested_attributes.all_emails: Direcciones de correo electrónico en su cuenta help_text.requested_attributes.birthdate: Fecha de nacimiento +help_text.requested_attributes.consent_reminder_html: Debe dar su consentimiento cada año para divulgar su información a %{sp_html}. help_text.requested_attributes.email: Dirección de correo electrónico help_text.requested_attributes.full_name: Nombre completo -help_text.requested_attributes.ial1_consent_reminder_html: Debe dar su consentimiento cada año para divulgar su información a %{sp}. Divulgaremos su información a %{sp} para conectar su cuenta. -help_text.requested_attributes.ial1_intro_html: Divulgaremos su información a %{sp} para conectar su cuenta. -help_text.requested_attributes.ial2_consent_reminder_html: 'Para conectar su cuenta, %{sp} necesita saber quién es usted. Debe dar su consentimiento cada año para divulgar su información verificada a %{sp}. Divulgaremos esta información:' -help_text.requested_attributes.ial2_intro_html: 'Para conectar su cuenta, %{sp} necesita saber quién es usted. Divulgaremos esta información a %{sp}:' -help_text.requested_attributes.ial2_reverified_consent_info: 'Como volvió a verificar su identidad, necesitamos su permiso para divulgar esta información a %{sp}:' +help_text.requested_attributes.ial2_reverified_consent_info_html: 'Como volvió a verificar su identidad, necesitamos su permiso para divulgar esta información a %{sp_html}:' +help_text.requested_attributes.intro_html: 'Divulgaremos esta información a %{sp_html}:' help_text.requested_attributes.phone: Número de teléfono help_text.requested_attributes.social_security_number: Número de Seguro Social help_text.requested_attributes.verified_at: Actualizado en diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a1489bc0f48..9a9665b2fc2 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -958,13 +958,11 @@ headings.webauthn_setup.new: Insérer votre clé de sécurité help_text.requested_attributes.address: Adresse help_text.requested_attributes.all_emails: Adresses e-mail sur votre compte help_text.requested_attributes.birthdate: Date de naissance +help_text.requested_attributes.consent_reminder_html: Vous devez consentir chaque année au partage de vos informations avec %{sp_html}. help_text.requested_attributes.email: Adresse e-mail help_text.requested_attributes.full_name: Nom complet -help_text.requested_attributes.ial1_consent_reminder_html: Vous devez consentir chaque année au partage de vos informations avec %{sp}. Nous partagerons vos informations avec %{sp} pour connecter votre compte. -help_text.requested_attributes.ial1_intro_html: Nous partagerons vos informations avec %{sp} pour connecter votre compte. -help_text.requested_attributes.ial2_consent_reminder_html: '%{sp} a besoin de savoir qui vous êtes pour se connecter à votre compte. Vous devez consentir chaque année à partager vos informations vérifiées avec %{sp}. Nous partagerons ces informations :' -help_text.requested_attributes.ial2_intro_html: '%{sp} a besoin de savoir qui vous êtes pour connecter votre compte. Nous partagerons ces informations avec %{sp} :' -help_text.requested_attributes.ial2_reverified_consent_info: 'Étant donné que vous avez revérifié votre identité, nous avons besoin de votre autorisation pour partager ces informations avec %{sp} :' +help_text.requested_attributes.ial2_reverified_consent_info_html: 'Étant donné que vous avez revérifié votre identité, nous avons besoin de votre autorisation pour partager ces informations avec %{sp_html} :' +help_text.requested_attributes.intro_html: 'Nous partagerons ces informations avec %{sp_html}:' help_text.requested_attributes.phone: Numéro de téléphone help_text.requested_attributes.social_security_number: Numéro de sécurité sociale help_text.requested_attributes.verified_at: Mis à jour le diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 316555349c5..1e6cb2d59f3 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -971,13 +971,11 @@ headings.webauthn_setup.new: 插入您的安全密钥 help_text.requested_attributes.address: 地址 help_text.requested_attributes.all_emails: 你账户上的电邮地址 help_text.requested_attributes.birthdate: 生日 +help_text.requested_attributes.consent_reminder_html: 你每年都必须授权同意与 %{sp_html} 分享信息。 help_text.requested_attributes.email: 电邮地址 help_text.requested_attributes.full_name: 姓名 -help_text.requested_attributes.ial1_consent_reminder_html: 你每年都必须授权同意与 %{sp} 分享信息。我们将与 %{sp} 分享你的信息来连接你账户。 -help_text.requested_attributes.ial1_intro_html: 我们将与 %{sp} 分享你的信息来连接你账户。 -help_text.requested_attributes.ial2_consent_reminder_html: '%{sp} 需要知道你是谁才能连接你的账户。你每年都必须授权同意与 %{sp} 分享已验证过的你的信息。我们会分享这些信息:' -help_text.requested_attributes.ial2_intro_html: '%{sp} 需要知道你是谁才能连接你的账户。我们会与 %{sp} 分享这些信息:' -help_text.requested_attributes.ial2_reverified_consent_info: '因为你重新验证了身份,我们需要得到你的许可才能与 %{sp} 分享该信息。' +help_text.requested_attributes.ial2_reverified_consent_info_html: '因为你重新验证了身份,我们需要得到你的许可才能与 %{sp_html} 分享该信息。' +help_text.requested_attributes.intro_html: 我们会与 %{sp_html} 分享这些信息: help_text.requested_attributes.phone: 电话号码 help_text.requested_attributes.social_security_number: 社会保障号码 help_text.requested_attributes.verified_at: 更新是在 diff --git a/spec/presenters/completions_presenter_spec.rb b/spec/presenters/completions_presenter_spec.rb index 102087eaa70..07c32b8deb1 100644 --- a/spec/presenters/completions_presenter_spec.rb +++ b/spec/presenters/completions_presenter_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe CompletionsPresenter do + include ActionView::Helpers::OutputSafetyHelper + include ActionView::Helpers::TagHelper + let(:identities) do [ build( @@ -147,43 +150,49 @@ end describe '#intro' do - describe 'ial1' do - context 'consent has expired since the last sign in' do - let(:identities) do - [ - build( - :service_provider_identity, - service_provider: current_sp.issuer, - last_consented_at: 2.years.ago, - ), - ] - end - let(:completion_context) { :consent_expired } + it 'renders the standard intro message' do + expect(presenter.intro).to eq( + t( + 'help_text.requested_attributes.intro_html', + sp_html: content_tag(:strong, current_sp.friendly_name), + ), + ) + end - it 'renders the expired IAL1 consent intro message' do - expect(presenter.intro).to eq( - I18n.t( - 'help_text.requested_attributes.ial1_consent_reminder_html', - sp: current_sp.friendly_name, - ), - ) - end + context 'consent has expired since the last sign in' do + let(:identities) do + [ + build( + :service_provider_identity, + service_provider: current_sp.issuer, + last_consented_at: 2.years.ago, + ), + ] end + let(:completion_context) { :consent_expired } - context 'when consent has not expired' do - it 'renders the standard intro message' do - expect(presenter.intro).to eq( - I18n.t( - 'help_text.requested_attributes.ial1_intro_html', - sp: current_sp.friendly_name, - ), - ) - end + it 'renders the expired consent intro message' do + expect(presenter.intro).to eq( + safe_join( + [ + t( + 'help_text.requested_attributes.consent_reminder_html', + sp_html: content_tag(:strong, current_sp.friendly_name), + ), + t( + 'help_text.requested_attributes.intro_html', + sp_html: content_tag(:strong, current_sp.friendly_name), + ), + ], + ' ', + ), + ) end end describe 'ial2' do let(:ial2_requested) { true } + context 'consent has expired since the last sign in' do let(:identities) do [ @@ -196,11 +205,20 @@ end let(:completion_context) { :consent_expired } - it 'renders the expired IAL2 consent intro message' do + it 'renders the expired consent intro message' do expect(presenter.intro).to eq( - I18n.t( - 'help_text.requested_attributes.ial2_consent_reminder_html', - sp: current_sp.friendly_name, + safe_join( + [ + t( + 'help_text.requested_attributes.consent_reminder_html', + sp_html: content_tag(:strong, current_sp.friendly_name), + ), + t( + 'help_text.requested_attributes.intro_html', + sp_html: content_tag(:strong, current_sp.friendly_name), + ), + ], + ' ', ), ) end @@ -217,22 +235,12 @@ ] end let(:completion_context) { :reverified_after_consent } - it 'renders the reverified IAL2 consent intro message' do - expect(presenter.intro).to eq( - I18n.t( - 'help_text.requested_attributes.ial2_reverified_consent_info', - sp: current_sp.friendly_name, - ), - ) - end - end - context 'when consent has not expired' do - it 'renders the standard intro message' do + it 'renders the reverified IAL2 consent intro message' do expect(presenter.intro).to eq( - I18n.t( - 'help_text.requested_attributes.ial2_intro_html', - sp: current_sp.friendly_name, + t( + 'help_text.requested_attributes.ial2_reverified_consent_info_html', + sp_html: content_tag(:strong, current_sp.friendly_name), ), ) end diff --git a/spec/views/sign_up/completions/show.html.erb_spec.rb b/spec/views/sign_up/completions/show.html.erb_spec.rb index 41938c7ff20..ee045ce15f1 100644 --- a/spec/views/sign_up/completions/show.html.erb_spec.rb +++ b/spec/views/sign_up/completions/show.html.erb_spec.rb @@ -43,9 +43,9 @@ expect(text).to_not include(service_provider.agency.name) expect(text).to include( view_context.strip_tags( - I18n.t( - 'help_text.requested_attributes.ial1_intro_html', - sp: service_provider.friendly_name, + t( + 'help_text.requested_attributes.intro_html', + sp_html: content_tag(:strong, service_provider.friendly_name), ), ), )