Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions app/presenters/completions_presenter.rb
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>%{sp}</strong>. We’ll share your information with <strong>%{sp}</strong> to connect your account.
help_text.requested_attributes.ial1_intro_html: We’ll share your information with <strong>%{sp}</strong> to connect your account.
help_text.requested_attributes.ial2_consent_reminder_html: '<strong>%{sp}</strong> needs to know who you are to connect to your account. You must consent each year to share your verified information with <strong>%{sp}</strong>. We’ll share this information:'
help_text.requested_attributes.ial2_intro_html: '<strong>%{sp}</strong> 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
Expand Down
8 changes: 3 additions & 5 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>%{sp}</strong>. Divulgaremos su información a <strong>%{sp}</strong> para conectar su cuenta.
help_text.requested_attributes.ial1_intro_html: Divulgaremos su información a <strong>%{sp}</strong> para conectar su cuenta.
help_text.requested_attributes.ial2_consent_reminder_html: 'Para conectar su cuenta, <strong>%{sp}</strong> necesita saber quién es usted. Debe dar su consentimiento cada año para divulgar su información verificada a <strong>%{sp}</strong>. Divulgaremos esta información:'
help_text.requested_attributes.ial2_intro_html: 'Para conectar su cuenta, <strong>%{sp}</strong> 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
Expand Down
8 changes: 3 additions & 5 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>%{sp}</strong>. Nous partagerons vos informations avec <strong>%{sp}</strong> pour connecter votre compte.
help_text.requested_attributes.ial1_intro_html: Nous partagerons vos informations avec <strong>%{sp}</strong> pour connecter votre compte.
help_text.requested_attributes.ial2_consent_reminder_html: '<strong>%{sp}</strong> 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 <strong>%{sp}</strong>. Nous partagerons ces informations :'
help_text.requested_attributes.ial2_intro_html: '<strong>%{sp}</strong> 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
Expand Down
8 changes: 3 additions & 5 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 你每年都必须授权同意与 <strong>%{sp}</strong> 分享信息。我们将与 <strong>%{sp}</strong> 分享你的信息来连接你账户。
help_text.requested_attributes.ial1_intro_html: 我们将与 <strong>%{sp}</strong> 分享你的信息来连接你账户。
help_text.requested_attributes.ial2_consent_reminder_html: '<strong>%{sp}</strong> 需要知道你是谁才能连接你的账户。你每年都必须授权同意与 <strong>%{sp}</strong> 分享已验证过的你的信息。我们会分享这些信息:'
help_text.requested_attributes.ial2_intro_html: '<strong>%{sp}</strong> 需要知道你是谁才能连接你的账户。我们会与 %{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: 更新是在
Expand Down
102 changes: 55 additions & 47 deletions spec/presenters/completions_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require 'rails_helper'

RSpec.describe CompletionsPresenter do
include ActionView::Helpers::OutputSafetyHelper
include ActionView::Helpers::TagHelper

let(:identities) do
[
build(
Expand Down Expand Up @@ -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
[
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/views/sign_up/completions/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
),
)
Expand Down