Skip to content

Commit

Permalink
Merge pull request #2042 from DFE-Digital/improve-factories
Browse files Browse the repository at this point in the history
Simplify assessment request traits
  • Loading branch information
thomasleese authored Feb 27, 2024
2 parents 2530674 + e6bfb46 commit 254723e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 46 deletions.
43 changes: 12 additions & 31 deletions spec/factories/assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions spec/factories/further_information_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/consent_letter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
20 changes: 12 additions & 8 deletions spec/services/destroy_application_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:,
)

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down
1 change: 1 addition & 0 deletions spec/system/teacher_interface/further_information_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def application_form
create(
:application_form,
:submitted,
:with_work_history,
statuses: %w[waiting_on_further_information],
teacher:,
)
Expand Down

0 comments on commit 254723e

Please sign in to comment.