Skip to content

Commit

Permalink
Merge pull request #9301 from DFE-Digital/dy-template-error-disabilit…
Browse files Browse the repository at this point in the history
…ies-nil

Template Error when disabilities are nil
  • Loading branch information
dcyoung-dev authored Apr 22, 2024
2 parents 236d295 + 8628bbc commit e76ed33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def offer_context
end

def disability_value
disabilities = equality_and_diversity['disabilities'].map do |disability|
disabilities = Array(equality_and_diversity['disabilities'])
disability_list_items = disabilities.map do |disability|
"<li>#{disability} </li>"
end

"<ul class=\"govuk-list\">#{disabilities.join}</ul>"
"<ul class=\"govuk-list\">#{disability_list_items.join}</ul>"
end

def application_in_correct_state?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
expect(result.text).to include('Chinese')
end

it 'does not dispay Ethnic background if they are not declared' do
it 'does not display Ethnic background if they are not declared' do
prefer_not_to_say_diversity_info = { 'sex' => 'Prefer not to say',
'disabilities' => ['I do not have any of these disabilities or health conditions'],
'ethnic_group' => 'Prefer not to say',
Expand Down Expand Up @@ -119,6 +119,26 @@
result = render_inline(described_class.new(application_choice:, current_provider_user: provider_user))
expect(result.text).to include('Prefer not to say')
end

it 'displays nothing for disabilities when they are nil' do
nil_disabilities_diversity_info = { 'sex' => 'female',
'disabilities' => nil,
'ethnic_group' => 'Asian or Asian British',
'ethnic_background' => 'Chinese' }

application_form = build_stubbed(
:application_form,
equality_and_diversity: nil_disabilities_diversity_info,
)
application_choice = build(:application_choice,
application_form:,
course:,
current_course: course,
status: 'pending_conditions')

result = render_inline(described_class.new(application_choice:, current_provider_user: provider_user))
expect(result.text).to include('Disabilities and health conditions')
end
end

context 'when provider user does not have permissions to view diversity information and the application is accepted' do
Expand Down

0 comments on commit e76ed33

Please sign in to comment.