From 53c0daea0c63e1d0d2274bb6422c42a32329c871 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 13 Mar 2024 14:44:15 +0000 Subject: [PATCH] Handle existing applications This updates the qualification verification tasks to handle the case where the qualification has gone out without consent being selected. --- app/lib/application_form_status_updater.rb | 9 ++++++--- .../qualification_requests_view_object.rb | 3 ++- lib/tasks/example_data.rake | 2 ++ .../assessor_interface/completing_assessment_spec.rb | 8 +++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/lib/application_form_status_updater.rb b/app/lib/application_form_status_updater.rb index 8b41c940e9..2503a1a5b4 100644 --- a/app/lib/application_form_status_updater.rb +++ b/app/lib/application_form_status_updater.rb @@ -164,15 +164,18 @@ def need_to_request_lops? end def need_to_request_consent? - qualification_requests.any?(&:consent_method_unknown?) || - consent_requests.any?(&:not_requested?) + ( + qualification_requests.none?(&:requested?) && + qualification_requests.any?(&:consent_method_unknown?) + ) || consent_requests.any?(&:not_requested?) end def need_to_request_ecctis? qualification_requests .select(&:not_requested?) .any? do |qualification_request| - qualification_request.consent_method_unsigned? || + qualification_request.consent_method_none? || + qualification_request.consent_method_unsigned? || consent_requests .select(&:verify_passed?) .any? do |consent_request| diff --git a/app/view_objects/assessor_interface/qualification_requests_view_object.rb b/app/view_objects/assessor_interface/qualification_requests_view_object.rb index 70e46ccedd..29a4d01160 100644 --- a/app/view_objects/assessor_interface/qualification_requests_view_object.rb +++ b/app/view_objects/assessor_interface/qualification_requests_view_object.rb @@ -30,7 +30,8 @@ def all_task_items end def all_consent_methods_selected? - qualification_requests.none?(&:consent_method_unknown?) + qualification_requests.none?(&:consent_method_unknown?) || + qualification_requests.requested.exists? end def show_individual_task_items? diff --git a/lib/tasks/example_data.rake b/lib/tasks/example_data.rake index cd7422d78a..4dfea6988e 100644 --- a/lib/tasks/example_data.rake +++ b/lib/tasks/example_data.rake @@ -235,11 +235,13 @@ def create_application_forms :selected_failure_reason, :fi_requestable, assessment_section: assessment.sections.first, + key: assessment.sections.first.failure_reasons.sample, ) FactoryBot.create( :selected_failure_reason, :declinable, assessment_section: assessment.sections.second, + key: assessment.sections.second.failure_reasons.sample, ) declined_at = Faker::Time.between(from: 6.months.ago, to: Time.zone.now) diff --git a/spec/system/assessor_interface/completing_assessment_spec.rb b/spec/system/assessor_interface/completing_assessment_spec.rb index 9eb41a3adf..58762b6d66 100644 --- a/spec/system/assessor_interface/completing_assessment_spec.rb +++ b/spec/system/assessor_interface/completing_assessment_spec.rb @@ -175,7 +175,7 @@ then_i_see_the(:assessor_application_status_page, reference:) when_i_click_on_overview_button - then_the_application_form_is_waiting_on + then_the_application_form_is_verification_in_progress end it "decline" do @@ -437,6 +437,12 @@ def then_the_application_form_is_waiting_on ) end + def then_the_application_form_is_verification_in_progress + expect(assessor_application_page.status_summary.value.text).to include( + "VERIFICATION IN PROGRESS", + ) + end + def then_the_application_form_is_declined expect(assessor_application_page.status_summary.value).to have_text( "DECLINED",