Skip to content

Commit

Permalink
Add edge case when the questions are not answered
Browse files Browse the repository at this point in the history
We shouldn't display the content for yes or no
  • Loading branch information
tomas-stefano committed Jun 28, 2024
1 parent 4addcd0 commit 83b1daf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/components/a_level_row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def a_level_subject_row_content(a_level_subject_requirement)
end

def pending_a_level_summary_content
I18n.t("course.consider_pending_a_level.row.#{@course.accept_pending_a_level?}")
I18n.t("course.consider_pending_a_level.row.#{@course.accept_pending_a_level?}") unless @course.accept_pending_a_level.nil?
end

def a_level_equivalency_summary_content
I18n.t("course.a_level_equivalencies.row.#{@course.accept_a_level_equivalency?}")
I18n.t("course.a_level_equivalencies.row.#{@course.accept_a_level_equivalency?}") unless @course.accept_a_level_equivalency.nil?
end

def inset_text_css_classes
Expand Down
18 changes: 18 additions & 0 deletions spec/components/a_level_row_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@
expect(rendered_component.text).not_to include('Some additional information')
end

it 'does not render the pending A level if the question is not answered' do
a_level_subject_requirement = { 'subject' => 'other_subject', 'other_subject' => 'Math', 'minimum_grade_required' => 'A' }
course = create(:course, accept_pending_a_level: nil, a_level_requirements: true, a_level_subject_requirements: [a_level_subject_requirement])
component = described_class.new(course: course.decorate)
rendered_component = render_inline(component)

expect(rendered_component.text).not_to include('Candidates with pending A levels will')
end

it 'does not render the equivalency A level if the question is not answered' do
a_level_subject_requirement = { 'subject' => 'other_subject', 'other_subject' => 'Math', 'minimum_grade_required' => 'A' }
course = create(:course, accept_a_level_equivalency: nil, a_level_requirements: true, a_level_subject_requirements: [a_level_subject_requirement])
component = described_class.new(course: course.decorate)
rendered_component = render_inline(component)

expect(rendered_component.text).not_to include('Equivalency tests will ')
end

it 'returns false for has_errors?' do
course = create(:course)
component = described_class.new(course: course.decorate)
Expand Down

0 comments on commit 83b1daf

Please sign in to comment.