From 8e5c98bf9459535e437ec525bd5a3835cfe056a4 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 6 Oct 2023 11:26:19 +0100 Subject: [PATCH] Move application form to review status This adds to the status updater service, which moves the application form to the review stage and status when an admin requests an application to be sent to review. --- app/lib/application_form_status_updater.rb | 13 ++++++++++--- spec/factories/assessments.rb | 5 +++++ spec/lib/application_form_status_updater_spec.rb | 11 +++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/lib/application_form_status_updater.rb b/app/lib/application_form_status_updater.rb index 9d86cb1292..33321ed965 100644 --- a/app/lib/application_form_status_updater.rb +++ b/app/lib/application_form_status_updater.rb @@ -182,8 +182,9 @@ def action_required_by "none" elsif preliminary_check? "admin" - elsif dqt_trn_request.present? || overdue_further_information || - overdue_lops || overdue_qualification || overdue_reference || + elsif dqt_trn_request.present? || assessment_in_review? || + overdue_further_information || overdue_lops || + overdue_qualification || overdue_reference || received_further_information || received_lops || received_qualification || received_reference "assessor" @@ -203,7 +204,7 @@ def stage application_form.declined_at.present? || application_form.awarded_at.present? "completed" - elsif dqt_trn_request.present? + elsif assessment_in_review? || dqt_trn_request.present? "review" elsif preliminary_check? || (teaching_authority_provides_written_statement && waiting_on_lops) @@ -240,6 +241,8 @@ def statuses elsif assessment.present? if preliminary_check? %w[preliminary_check] + requestable_statuses + elsif assessment_in_review? + %w[review] elsif requestable_statuses.present? requestable_statuses elsif assessment.any_not_preliminary_section_finished? @@ -270,6 +273,10 @@ def preliminary_check? ) end + def assessment_in_review? + assessment&.review? || false + end + def requestable_statuses @requestable_statuses ||= %w[overdue received waiting_on] diff --git a/spec/factories/assessments.rb b/spec/factories/assessments.rb index 7e48efd8e7..c9190ada00 100644 --- a/spec/factories/assessments.rb +++ b/spec/factories/assessments.rb @@ -52,6 +52,11 @@ recommended_at { Time.zone.now } end + trait :review do + recommendation { "review" } + recommended_at { Time.zone.now } + end + trait :with_preliminary_qualifications_section do after(:create) do |assessment, _evaulator| create(:assessment_section, :preliminary, :qualifications, assessment:) diff --git a/spec/lib/application_form_status_updater_spec.rb b/spec/lib/application_form_status_updater_spec.rb index d5e64460e1..1d89a43d7f 100644 --- a/spec/lib/application_form_status_updater_spec.rb +++ b/spec/lib/application_form_status_updater_spec.rb @@ -430,6 +430,17 @@ end end + context "when a reviewed assessment" do + before do + application_form.update!(submitted_at: Time.zone.now) + create(:assessment, :review, application_form:) + end + + include_examples "changes action required by", "assessor" + include_examples "changes stage", "review" + include_examples "changes statuses", %w[review] + end + context "with a started assessment" do before do application_form.update!(submitted_at: Time.zone.now)