Skip to content

Commit

Permalink
seeds don't create invalid vacancies (#7415)
Browse files Browse the repository at this point in the history
  • Loading branch information
starswan authored Jan 16, 2025
1 parent 7b3b9d5 commit eaa4d95
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,20 @@
location_preference_names = weydon_trust_schools.map(&:postcode)

Jobseeker.first(weydon_trust_schools.count).each do |jobseeker|
FactoryBot.create(:jobseeker_profile, :with_personal_details, :with_qualifications, :with_employment_history, jobseeker: jobseeker) do |jobseeker_profile|
FactoryBot.create(:job_preferences, jobseeker_profile: jobseeker_profile) do |job_preferences|
FactoryBot.create(:job_preferences_location, job_preferences:, name: location_preference_names.pop)
end
# :with_employment_history trait creates a job_application through the factory, which in turn creates a vacancy that has no associated organisation and causes review app to break on the jobs page and causes smoke test failures
jobseeker_profile.employments.each do |employment|
vacancy_without_org_id = employment.job_application.vacancy_id
OrganisationVacancy.create(vacancy_id: vacancy_without_org_id, organisation_id: weydon_trust_schools.first.id)
end
# :with_qualifications trait also creates a job_application through the factory, which in turn creates a vacancy that has no associated organisation and causes review app to break on the jobs page and causes smoke test failures.
jobseeker_profile.qualifications.each do |qualification|
vacancy_without_org_id = qualification.job_application.vacancy_id
OrganisationVacancy.create(vacancy_id: vacancy_without_org_id, organisation_id: weydon_trust_schools.first.id)
Jobseeker.transaction do
FactoryBot.create(:jobseeker_profile, :with_personal_details,
qualifications: FactoryBot.build_list(:qualification, 1,
job_application: FactoryBot.build(:job_application,
vacancy: FactoryBot.build(:vacancy,
organisations: weydon_trust_schools))),
employments: FactoryBot.build_list(:employment, 1,
job_application: FactoryBot.build(:job_application,
vacancy: FactoryBot.build(:vacancy,
organisations: weydon_trust_schools))),
jobseeker: jobseeker) do |jobseeker_profile|
FactoryBot.create(:job_preferences, jobseeker_profile: jobseeker_profile) do |job_preferences|
FactoryBot.create(:job_preferences_location, job_preferences:, name: location_preference_names.pop)
end
end
end
end

0 comments on commit eaa4d95

Please sign in to comment.