Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[594] Surface whether candidate has a one login account on support #10295

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
13 changes: 13 additions & 0 deletions app/components/support_interface/application_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ApplicationSummaryComponent < ViewComponent::Base
:submitted_at,
:submitted?,
:updated_at,
:candidate,
to: :application_form

def initialize(application_form:)
Expand All @@ -25,6 +26,7 @@ def rows
subsequent_application_row,
average_distance_row,
editable_extension_row,
one_login_account_row,
].compact
end

Expand Down Expand Up @@ -85,6 +87,13 @@ def candidate_id_row
}
end

def one_login_account_row
{
key: 'Has One Login account',
value: one_login? ? 'Yes' : 'No',
}
end

def state_row
{
key: 'State',
Expand Down Expand Up @@ -140,6 +149,10 @@ def formatted_status
"<strong>#{name}</strong><br>#{desc}".html_safe
end

def one_login?
candidate.one_login_connected?
end

attr_reader :application_form
end
end
4 changes: 4 additions & 0 deletions app/models/candidate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def recoverable?
!application_choices_submitted?
end

def one_login_connected?
one_login_auth.present?
end

private

def downcase_email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,53 @@
expect(result.css('.govuk-summary-list__key').text).not_to include('Is this application editable')
end
end

context 'when the candidate has a OneLogin account' do
it 'displays "Yes" for the One Login account row' do
candidate = create(:candidate)
candidate.create_one_login_auth!(
token: '123',
email_address: candidate.email_address,
)
application_form = create(:completed_application_form, candidate:)

result = render_inline(described_class.new(application_form:))

expect(result.css('.govuk-summary-list__key').text).to include('Has One Login account')
expect(result.css('.govuk-summary-list__value').text).to include('Yes')
end
end

context 'when the candidate does not have a OneLogin account' do
it 'displays "No" for the One Login account row' do
candidate = create(:candidate)
application_form = create(:completed_application_form, candidate:)

result = render_inline(described_class.new(application_form:))

expect(result.css('.govuk-summary-list__key').text).to include('Has One Login account')
expect(result.css('.govuk-summary-list__value').text).to include('No')
end
end

context 'when the candidate had a OneLogin account but it was deleted' do
it 'displays "No" for the One Login account row' do
candidate = create(:candidate)
one_login_auth = candidate.create_one_login_auth!(
token: '123',
email_address: candidate.email_address,
)

one_login_auth.delete
candidate.reload

application_form = create(:completed_application_form, candidate:)

result = render_inline(described_class.new(application_form:))

expect(result.css('.govuk-summary-list__key').text).to include('Has One Login account')
expect(result.css('.govuk-summary-list__value').text).to include('No')
end
end
end
end
18 changes: 18 additions & 0 deletions spec/models/candidate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,22 @@
end
end
end

describe '#one_login_connected?' do
let(:candidate) { create(:candidate) }

context 'when the candidate has a OneLoginAuth record' do
before { create(:one_login_auth, candidate:) }

it 'returns true' do
expect(candidate.one_login_connected?).to be true
end
end

context 'when the candidate does not have a OneLoginAuth record' do
it 'returns false' do
expect(candidate.one_login_connected?).to be false
end
end
end
end
Loading