diff --git a/app/models/further_information_request.rb b/app/models/further_information_request.rb index c44d8be199..a65ce35c78 100644 --- a/app/models/further_information_request.rb +++ b/app/models/further_information_request.rb @@ -33,7 +33,7 @@ class FurtherInformationRequest < ApplicationRecord -> do where .not(requested_at: nil) - .where(expired_at: nil) + .where(expired_at: nil, received_at: nil) .joins(assessment: :application_form) .merge(ApplicationForm.assessable) end diff --git a/app/models/reference_request.rb b/app/models/reference_request.rb index 24c0d77a0f..0ba293fb0d 100644 --- a/app/models/reference_request.rb +++ b/app/models/reference_request.rb @@ -62,7 +62,7 @@ class ReferenceRequest < ApplicationRecord -> do where .not(requested_at: nil) - .where(expired_at: nil) + .where(expired_at: nil, received_at: nil) .joins(assessment: :application_form) .merge(ApplicationForm.assessable) end diff --git a/app/services/expire_requestable.rb b/app/services/expire_requestable.rb index b6806fdba2..92ef8e7ea1 100644 --- a/app/services/expire_requestable.rb +++ b/app/services/expire_requestable.rb @@ -9,7 +9,7 @@ def initialize(requestable:, user:) end def call - raise NotRequested unless requestable.requested? + raise InvalidState if invalid_state? ActiveRecord::Base.transaction do requestable.expired! @@ -21,7 +21,7 @@ def call requestable end - class NotRequested < StandardError + class InvalidState < StandardError end private @@ -30,6 +30,10 @@ class NotRequested < StandardError delegate :application_form, to: :requestable + def invalid_state? + requestable.expired? || requestable.received? || !requestable.requested? + end + def create_timeline_event creator = user.is_a?(String) ? nil : user creator_name = user.is_a?(String) ? user : "" 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 c5ea3abc6a..5949371f00 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 @@ -236,9 +236,9 @@ def further_information_request_task_list_item(further_information_request) ] end, status: - if further_information_request.requested? + if !further_information_request.received? :cannot_start - elsif further_information_request.review_passed.nil? + elsif !further_information_request.reviewed? :not_started elsif assessment.request_further_information? :in_progress diff --git a/spec/factories/further_information_requests.rb b/spec/factories/further_information_requests.rb index cfb1d787d3..350cbb810b 100644 --- a/spec/factories/further_information_requests.rb +++ b/spec/factories/further_information_requests.rb @@ -31,10 +31,12 @@ end trait :received do + requested received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end trait :expired do + requested expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end diff --git a/spec/factories/professional_standing_requests.rb b/spec/factories/professional_standing_requests.rb index 90c89e63f6..63b710a8af 100644 --- a/spec/factories/professional_standing_requests.rb +++ b/spec/factories/professional_standing_requests.rb @@ -37,11 +37,13 @@ end trait :received do - received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + requested receivable + received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end trait :expired do + requested expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end diff --git a/spec/factories/reference_requests.rb b/spec/factories/reference_requests.rb index 58d1aa4791..cb339bf615 100644 --- a/spec/factories/reference_requests.rb +++ b/spec/factories/reference_requests.rb @@ -68,11 +68,13 @@ end trait :received do - received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } + requested receivable + received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end trait :expired do + requested expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } end diff --git a/spec/services/expire_requestable_spec.rb b/spec/services/expire_requestable_spec.rb index 1ccb78b8f7..1ed05ca6bd 100644 --- a/spec/services/expire_requestable_spec.rb +++ b/spec/services/expire_requestable_spec.rb @@ -30,7 +30,7 @@ shared_examples_for "not expiring a requestable" do it "raises an error" do - expect { call }.to raise_error(ExpireRequestable::NotRequested) + expect { call }.to raise_error(ExpireRequestable::InvalidState) end end 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 ae9a464c01..c917b2328d 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 @@ -91,12 +91,8 @@ ) end - it do - is_expected.to_not include_task_list_section( - "Further information requests", - ) - end - it { is_expected.to_not include_task_list_section("Verification requests") } + it { is_expected.to_not include_task_list_section("Verification") } + it { is_expected.to_not include_task_list_section("Review") } context "when teaching authority provides written statement and a professional standing request" do let!(:professional_standing_request) do