Skip to content

Commit

Permalink
Add waiting on personas
Browse files Browse the repository at this point in the history
This adds a couple of new personas when waiting on consent or waiting on
further information.
  • Loading branch information
thomasleese committed Feb 13, 2024
1 parent 5f38e58 commit 2216050
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
18 changes: 10 additions & 8 deletions app/controllers/personas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ def load_eligible_personas
%w[online written none]
.product(
%w[online written none],
%w[draft not_started verification awarded declined],
%w[
draft
not_started
waiting_on_consent
waiting_on_further_information
awarded
declined
],
)
.map do |status_check, sanction_check, stage_or_status|
{ status_check:, sanction_check:, stage_or_status: }
Expand Down Expand Up @@ -148,13 +155,8 @@ def load_teacher_personas

stage_or_status = persona[:stage_or_status]

if stage_or_status == "awarded"
application_form.awarded_at.present?
elsif stage_or_status == "declined"
application_form.declined_at.present?
else
application_form.stage == stage_or_status
end
application_form.stage == stage_or_status ||
application_form.statuses.include?(stage_or_status)
end

if (application_form = found_application_form)
Expand Down
37 changes: 6 additions & 31 deletions lib/tasks/example_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ def application_form_traits_for(region)
end

def create_requestables(application_form, assessment, state)
status_prefix = {
expired: "overdue",
received: "received",
requested: "waiting_on",
}.fetch(state)

unless application_form.teaching_authority_provides_written_statement
assessment.sections.update_all(passed: true)
end
Expand All @@ -173,18 +167,6 @@ def create_requestables(application_form, assessment, state)
)
FactoryBot.create(:professional_standing_request, state, assessment:)

application_form.update!(
statuses: ["#{status_prefix}_lops"],
stage:
(
if application_form.teaching_authority_provides_written_statement
"pre_assessment"
else
"verification"
end
),
)

unless application_form.teaching_authority_provides_written_statement
assessment.verify!
end
Expand All @@ -194,26 +176,18 @@ def create_requestables(application_form, assessment, state)
FactoryBot.create(:reference_request, state, assessment:, work_history:)
end

application_form.update!(
statuses: ["#{status_prefix}_reference"],
stage: "verification",
)
assessment.verify!
elsif (qualifications = application_form.qualifications).present? &&
rand(2).zero?
qualifications.each do |qualification|
FactoryBot.create(
:qualification_request,
state,
[state, "consent_#{state}"].sample,
assessment:,
qualification:,
)
end

application_form.update!(
statuses: ["#{status_prefix}_qualification"],
stage: "verification",
)
assessment.verify!
elsif state != :expired
FactoryBot.create(
Expand All @@ -222,12 +196,13 @@ def create_requestables(application_form, assessment, state)
:with_items,
assessment:,
)
application_form.update!(
statuses: ["#{status_prefix}_further_information"],
stage: "assessment",
)
assessment.request_further_information!
end

ApplicationFormStatusUpdater.call(
application_form:,
user: "Example data generator",
)
end

def create_application_forms
Expand Down
12 changes: 12 additions & 0 deletions spec/factories/qualification_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@
end
end

trait :consent_received do
consent_requested
consent_received_at do
Faker::Time.between(from: 1.month.ago, to: Time.zone.now)
end
end

trait :consent_expired do
consent_requested
expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) }
end

trait :requested do
requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) }
end
Expand Down

0 comments on commit 2216050

Please sign in to comment.