From 86f3ff83b3325e9bb23189741a47539368b09c1c Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 5 Oct 2023 12:16:45 +0100 Subject: [PATCH] Add review task list items This adds a new task list item for assessors for accessing any verifications that need reviewing. --- .../application_forms_show_view_object.rb | 115 ++++++++++++++---- config/locales/assessor_interface.en.yml | 5 +- ...application_forms_show_view_object_spec.rb | 47 ++++++- 3 files changed, 140 insertions(+), 27 deletions(-) diff --git a/app/view_objects/assessor_interface/application_forms_show_view_object.rb b/app/view_objects/assessor_interface/application_forms_show_view_object.rb index 8f5e2db1cc..c5ea3abc6a 100644 --- a/app/view_objects/assessor_interface/application_forms_show_view_object.rb +++ b/app/view_objects/assessor_interface/application_forms_show_view_object.rb @@ -23,6 +23,7 @@ def task_list_sections pre_assessment_task_list_section, assessment_task_list_section, verification_task_list_section, + review_task_list_section, ].compact end @@ -83,7 +84,10 @@ def management_tasks :teaching_authority_provides_written_statement, :work_histories, to: :application_form - delegate :professional_standing_request, to: :assessment + delegate :professional_standing_request, + :qualification_requests, + :reference_requests, + to: :assessment delegate :canonical_email, to: :teacher def pre_assessment_task_list_section @@ -254,7 +258,7 @@ def verification_task_list_section review_professional_standing_request_task_list_item, ].compact - items << assessment_recommendation_task_list_item if items.present? + items << verification_decision_task_list_item if items.present? { title: @@ -312,27 +316,6 @@ def reference_requests_task_list_item } end - def assessment_recommendation_task_list_item - { - name: - I18n.t( - "assessor_interface.application_forms.show.assessment_tasks.items.assessment_recommendation", - ), - link: - if assessment.recommendable? - [:edit, :assessor_interface, application_form, assessment] - end, - status: - if assessment.completed? - :completed - elsif !assessment.recommendable? - :cannot_start - else - :not_started - end, - } - end - def locate_professional_standing_request_task_list_item if teaching_authority_provides_written_statement || professional_standing_request.blank? @@ -397,6 +380,92 @@ def review_professional_standing_request_task_list_item } end + def verification_decision_task_list_item + { + name: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.items.verification_decision", + ), + link: + if assessment.verify? && assessment.recommendable? + [:edit, :assessor_interface, application_form, assessment] + end, + status: + if assessment.review? || assessment.completed? + :completed + elsif !assessment.recommendable? + :cannot_start + else + :not_started + end, + } + end + + def review_task_list_section + return unless pre_assessment_complete? + return if assessment.verify? + + if ( + !teaching_authority_provides_written_statement && + professional_standing_request&.verify_failed? + ) || qualification_requests.any?(&:verify_failed?) || + reference_requests.any?(&:verify_failed?) + { + title: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.sections.review", + ), + items: [ + review_verifications_task_list_item, + review_decision_task_list_item, + ], + } + end + end + + def review_verifications_task_list_item + { + name: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.items.review_verifications", + ), + link: [:edit, :assessor_interface, application_form, assessment], + status: + if assessment.recommendable? + :completed + elsif ( + !teaching_authority_provides_written_statement && + professional_standing_request&.reviewed? + ) || qualification_requests.any?(&:reviewed?) || + reference_requests.any?(&:reviewed?) + :in_progress + else + :not_started + end, + } + end + + def review_decision_task_list_item + { + name: + I18n.t( + "assessor_interface.application_forms.show.assessment_tasks.items.assessment_decision", + ), + link: + if assessment.recommendable? + [:edit, :assessor_interface, application_form, assessment] + end, + status: + if assessment.completed? + :completed + elsif !assessment.recommendable? + :cannot_start + else + :not_started + end, + } + end + def pre_assessment_complete? return false unless assessment.all_preliminary_sections_passed? diff --git a/config/locales/assessor_interface.en.yml b/config/locales/assessor_interface.en.yml index 729d4ead17..a44c957bb2 100644 --- a/config/locales/assessor_interface.en.yml +++ b/config/locales/assessor_interface.en.yml @@ -16,9 +16,10 @@ en: sections: assessment: Assessment pre_assessment_tasks: Pre-assessment tasks + review: Review verification: Verification items: - assessment_recommendation: Assessment recommendation + assessment_decision: Assessment decision await_professional_standing_request: Awaiting third-party professional standing initial_assessment_recommendation: Initial assessment recommendation locate_professional_standing_request: Record LOPS response @@ -26,6 +27,8 @@ en: reference_requests: Verify reference requests review_professional_standing_request: Review LOPS response review_requested_information: Review requested information from applicant + review_verifications: Review verifications + verification_decision: Verification decision assessments: edit: diff --git a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb index 0f78a1cea4..ae9a464c01 100644 --- a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb @@ -376,7 +376,7 @@ it do is_expected.to include_task_list_item( "Verification", - "Assessment recommendation", + "Verification decision", ) end end @@ -393,7 +393,7 @@ it do is_expected.to include_task_list_item( "Verification", - "Assessment recommendation", + "Verification decision", ) end end @@ -410,10 +410,51 @@ it do is_expected.to include_task_list_item( "Verification", - "Assessment recommendation", + "Verification decision", ) end end + + context "with a failed verified professional standing request" do + before do + create( + :professional_standing_request, + assessment:, + verify_passed: false, + ) + end + + it do + is_expected.to include_task_list_item("Review", "Review verifications") + end + it do + is_expected.to include_task_list_item("Review", "Assessment decision") + end + end + + context "with a failed verified qualification request" do + before do + create(:qualification_request, assessment:, verify_passed: false) + end + + it do + is_expected.to include_task_list_item("Review", "Review verifications") + end + it do + is_expected.to include_task_list_item("Review", "Assessment decision") + end + end + + context "with a failed verified reference request" do + before { create(:reference_request, assessment:, verify_passed: false) } + + it do + is_expected.to include_task_list_item("Review", "Review verifications") + end + it do + is_expected.to include_task_list_item("Review", "Assessment decision") + end + end end describe "#email_used_as_reference_in_this_application_form?" do