Skip to content

Commit

Permalink
Ensure fake requestable statuses are correct
Browse files Browse the repository at this point in the history
This updates the statuses for requestables to ensure they better
represent a real situation.
  • Loading branch information
thomasleese committed Apr 9, 2024
1 parent c53441f commit ae4e0f6
Showing 1 changed file with 34 additions and 45 deletions.
79 changes: 34 additions & 45 deletions app/lib/fake_data/application_form_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def call

return application_form unless params.receive_verification?

receive_verification
receive_references_and_consent

unless params.review? || params.decline_after_review? || params.award?
return application_form
Expand All @@ -82,7 +82,7 @@ def call
decline_application_form
elsif params.award?
review_verification(passed: true) if params.review?
award_application_form
award_application_form(user: params.review? ? assessor_user : admin_user)
end

application_form
Expand Down Expand Up @@ -378,14 +378,7 @@ def request_verification
end
end

def receive_verification
user = admin_user

if assessment.professional_standing_request.present? &&
!application_form.teaching_authority_provides_written_statement
receive_professional_standing
end

def receive_references_and_consent
assessment.reference_requests.each do |requestable|
contact_response = [true, false].sample
dates_response = [true, false].sample
Expand Down Expand Up @@ -426,41 +419,11 @@ def receive_verification
end
end

assessment.qualification_requests.each do |requestable|
consent_request =
assessment.consent_requests.find_by(
qualification: requestable.qualification,
)

if consent_request
FactoryBot.create(
:upload,
document: consent_request.signed_consent_document,
)

date_generator.travel_to_next_long do
ReceiveRequestable.call(
requestable: consent_request,
user: application_form.teacher,
)
end

date_generator.travel_to_next_long do
VerifyRequestable.call(
requestable: consent_request,
user:,
passed: true,
note: Faker::Lorem.sentence,
)
end

date_generator.travel_to_next_short do
RequestRequestable.call(requestable:, user:)
end
end
assessment.consent_requests.each do |requestable|
FactoryBot.create(:upload, document: requestable.signed_consent_document)

date_generator.travel_to_next_long do
ReceiveRequestable.call(requestable:, user:)
ReceiveRequestable.call(requestable:, user: application_form.teacher)
end
end
end
Expand All @@ -480,7 +443,34 @@ def overdue_verification
def verify_verification(passed:)
user = admin_user

if passed
assessment.consent_requests.each do |requestable|
date_generator.travel_to_next_short do
VerifyRequestable.call(requestable:, user:, passed: true, note: "")
end
end

assessment
.qualification_requests
.reject(&:requested?)
.each do |requestable|
date_generator.travel_to_next_short do
RequestRequestable.call(requestable:, user:)
end
end
end

requestables
.reject(&:received?)
.select { passed || [true, false].sample }
.each do |requestable|
date_generator.travel_to_next_long do
ReceiveRequestable.call(requestable:, user:)
end
end

requestables
.select(&:requested?)
.reject(&:verified?)
.each do |requestable|
date_generator.travel_to_next_short do
Expand Down Expand Up @@ -517,12 +507,11 @@ def review_verification(passed:)
end
end

def award_application_form
def award_application_form(user:)
assessment.award!

trn = Faker::Number.leading_zero_number(digits: 10)
access_your_teaching_qualifications_url = Faker::Internet.url
user = admin_user

date_generator.travel_to_next_long do
DQTTRNRequest.create!(request_id: SecureRandom.uuid, application_form:)
Expand Down

0 comments on commit ae4e0f6

Please sign in to comment.