Skip to content

Commit

Permalink
Refactor AssessmentSectionViewObject
Browse files Browse the repository at this point in the history
This renames a few of the methods to make them clearer.
  • Loading branch information
thomasleese committed Apr 11, 2024
1 parent eddf5ba commit 4f5332b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def show
end

def update
unless view_object.render_form?
unless view_object.show_form?
redirect_to [
:assessor_interface,
application_form,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def notes_placeholder_key_for(failure_reason:)
build_key(failure_reason, "placeholder")
end

def render_form?
def show_form?
return true if preliminary?

if requires_preliminary_check &&
!assessment.all_preliminary_sections_passed?
return false
end

return false if render_section_content?
return false if show_english_language_exemption_content?

if assessment_section.professional_standing? &&
!professional_standing_request_received?
Expand All @@ -61,7 +61,7 @@ def render_form?
true
end

def render_section_content?
def show_english_language_exemption_content?
assessment_section.english_language_proficiency? &&
application_form.english_language_exempt?
end
Expand All @@ -84,6 +84,10 @@ def show_english_language_exemption_checkbox?
)
end

def show_teacher_name_and_date_of_birth?
!assessment_section.personal_information?
end

def teacher_name_and_date_of_birth
[
application_form.given_names,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
title: t(".title.#{preliminary_key}.#{section_key}"),
application_form: @view_object.application_form %>

<% unless section_key == "personal_information" %>
<% if @view_object.show_teacher_name_and_date_of_birth? %>
<h2 class="govuk-heading-m"><%= @view_object.teacher_name_and_date_of_birth %></h2>
<% end %>

Expand All @@ -25,10 +25,10 @@
assessment_section: @view_object.assessment_section,
highlighted_work_history_contact_emails: @view_object.highlighted_work_history_contact_emails %>

<% if @view_object.render_form? %>
<% if @view_object.show_form? %>
<%= render "form", form: @form, view_object: @view_object %>
<% end %>

<% if @view_object.render_section_content? %>
<%= render "#{section_key}_content", application_form: @view_object.application_form %>
<% if @view_object.show_english_language_exemption_content? %>
<%= render "english_language_exemption_content", application_form: @view_object.application_form %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
end
end

describe "#render_form?" do
subject(:render_form?) { view_object.render_form? }
describe "#show_form?" do
subject(:show_form?) { view_object.show_form? }

it { is_expected.to be true }

Expand Down

0 comments on commit 4f5332b

Please sign in to comment.