Skip to content

Commit

Permalink
Move application form to review status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasleese committed Oct 6, 2023
1 parent c4f29b6 commit 7986396
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/lib/application_form_status_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions spec/factories/assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/application_form_status_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7986396

Please sign in to comment.