From e6bfb46afc39ea0b9de4fafa582f2733a8e42e11 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Tue, 27 Feb 2024 11:35:38 +0100 Subject: [PATCH] Simplify assessment request traits This simplifes the traits on the assessment factory to make it easier to create consent/reference/qualification requests. --- spec/factories/assessments.rb | 43 ++++++------------- .../factories/further_information_requests.rb | 6 +-- spec/lib/consent_letter_spec.rb | 4 +- .../services/destroy_application_form_spec.rb | 20 +++++---- .../reviewing_further_information_spec.rb | 3 +- .../further_information_spec.rb | 1 + 6 files changed, 31 insertions(+), 46 deletions(-) diff --git a/spec/factories/assessments.rb b/spec/factories/assessments.rb index 1f4d07748f..ec2e91e61f 100644 --- a/spec/factories/assessments.rb +++ b/spec/factories/assessments.rb @@ -74,13 +74,11 @@ end end - trait :with_consent_request do + trait :with_consent_requests do after(:create) do |assessment, _evaluator| - create( - :consent_request, - assessment:, - qualification: assessment.application_form.qualifications.first, - ) + assessment.application_form.qualifications.each do |qualification| + create(:consent_request, assessment:, qualification:) + end end end @@ -113,38 +111,21 @@ end end - trait :with_reference_request do - after(:create) do |assessment, _evaluator| - create( - :reference_request, - :requested, - assessment:, - work_history: assessment.application_form.work_histories.first, - ) - end - end - - trait :with_received_reference_request do + trait :with_reference_requests do after(:create) do |assessment, _evaluator| - create( - :reference_request, - :received, - assessment:, - work_history: assessment.application_form.work_histories.first, - ) + assessment.application_form.work_histories.each do |work_history| + create(:reference_request, :requested, assessment:, work_history:) + end end end - trait :with_qualification_request do + trait :with_qualification_requests do qualifications_assessor_note { Faker::Lorem.sentence } after(:create) do |assessment, _evaluator| - create( - :qualification_request, - :requested, - assessment:, - qualification: assessment.application_form.qualifications.first, - ) + assessment.application_form.qualifications.each do |qualification| + create(:qualification_request, assessment:, qualification:) + end end end end diff --git a/spec/factories/further_information_requests.rb b/spec/factories/further_information_requests.rb index 350cbb810b..31c2ee5304 100644 --- a/spec/factories/further_information_requests.rb +++ b/spec/factories/further_information_requests.rb @@ -68,11 +68,7 @@ :with_work_history_contact_response, further_information_request:, work_history: - create( - :work_history, - :completed, - application_form: further_information_request.application_form, - ), + further_information_request.application_form.work_histories.first, ) create( :further_information_request_item, diff --git a/spec/lib/consent_letter_spec.rb b/spec/lib/consent_letter_spec.rb index c182b18ea2..fcd7456654 100644 --- a/spec/lib/consent_letter_spec.rb +++ b/spec/lib/consent_letter_spec.rb @@ -11,7 +11,9 @@ ) end - before { create(:assessment, :with_qualification_request, application_form:) } + before do + create(:assessment, :with_qualification_requests, application_form:) + end describe "#render_pdf" do subject(:render_pdf) { described_class.new(application_form:).render_pdf } diff --git a/spec/services/destroy_application_form_spec.rb b/spec/services/destroy_application_form_spec.rb index 7642bf144b..3a05e3b5fe 100644 --- a/spec/services/destroy_application_form_spec.rb +++ b/spec/services/destroy_application_form_spec.rb @@ -6,21 +6,25 @@ before do 2.times do application_form = - create(:application_form, :submitted, :with_identification_document) + create( + :application_form, + :submitted, + :with_identification_document, + :with_teaching_qualification, + :with_work_history, + ) - create(:qualification, application_form:) - create(:work_history, application_form:) create(:note, application_form:) create(:dqt_trn_request, application_form:) assessment = create( :assessment, - :with_consent_request, + :with_consent_requests, :with_further_information_request, :with_professional_standing_request, - :with_qualification_request, - :with_reference_request, + :with_qualification_requests, + :with_reference_requests, application_form:, ) @@ -53,10 +57,10 @@ include_examples "deletes model", ProfessionalStandingRequest include_examples "deletes model", Qualification include_examples "deletes model", QualificationRequest - include_examples "deletes model", ReferenceRequest + include_examples "deletes model", ReferenceRequest, 4, 2 include_examples "deletes model", SelectedFailureReason include_examples "deletes model", Teacher include_examples "deletes model", TimelineEvent - include_examples "deletes model", Upload + include_examples "deletes model", Upload, 6, 3 include_examples "deletes model", WorkHistory, 4, 2 end diff --git a/spec/system/assessor_interface/reviewing_further_information_spec.rb b/spec/system/assessor_interface/reviewing_further_information_spec.rb index 38569fd7e5..4679ed74d6 100644 --- a/spec/system/assessor_interface/reviewing_further_information_spec.rb +++ b/spec/system/assessor_interface/reviewing_further_information_spec.rb @@ -115,8 +115,9 @@ def application_form @application_form ||= create( :application_form, - :with_personal_information, :submitted, + :with_personal_information, + :with_work_history, ).tap do |application_form| assessment = create(:assessment, :request_further_information, application_form:) diff --git a/spec/system/teacher_interface/further_information_spec.rb b/spec/system/teacher_interface/further_information_spec.rb index 74640ed55d..a34944f5f8 100644 --- a/spec/system/teacher_interface/further_information_spec.rb +++ b/spec/system/teacher_interface/further_information_spec.rb @@ -206,6 +206,7 @@ def application_form create( :application_form, :submitted, + :with_work_history, statuses: %w[waiting_on_further_information], teacher:, )