Load student respondent information from enrollment loader

This commit is contained in:
rebuilt 2023-02-27 12:29:16 -08:00
parent 79f7915edf
commit ae6d7151b3
5 changed files with 47 additions and 73 deletions

View file

@ -5,8 +5,12 @@ describe Seeder do
let(:seeder) { Seeder.new }
let(:lowell_seeder) { Seeder.new rules: [Rule::SeedOnlyLowell] }
after :each do
DatabaseCleaner.clean
end
context 'academic years' do
before { AcademicYear.delete_all }
# before { AcademicYear.delete_all }
it 'seeds new academic years' do
expect do
@ -53,7 +57,6 @@ describe Seeder do
create(:school, name: 'John Oldest Academy', dese_id: 12_345, district: existing_district)
end
let!(:removed_survey_item_response) { create(:survey_item_response, school: removed_school) }
let!(:removed_respondent) { create(:respondent, school: removed_school) }
let!(:removed_survey) { create(:survey, school: removed_school) }
let!(:existing_school) do
create(:school, name: 'Sam Adams Elementary School', dese_id: 350_302, slug: 'some-slug-for-sam-adams',
@ -96,7 +99,6 @@ describe Seeder do
expect(School.where(id: removed_school)).not_to exist
expect(SurveyItemResponse.where(id: removed_survey_item_response)).not_to exist
expect(Respondent.where(id: removed_respondent)).not_to exist
expect(Survey.where(id: removed_survey)).not_to exist
end
end
@ -113,48 +115,48 @@ describe Seeder do
end
end
context 'respondents' do
before :each do
create(:academic_year, range: '2020-21')
seeder.seed_districts_and_schools sample_districts_and_schools_csv
end
# context 'respondents' do
# before :each do
# create(:academic_year, range: '2020-21')
# seeder.seed_districts_and_schools sample_districts_and_schools_csv
# end
it 'seeds the total number of respondents for a school' do
expect do
seeder.seed_respondents sample_districts_and_schools_csv
end.to change { Respondent.count }.by(School.count)
end
# it 'seeds the total number of respondents for a school' do
# expect do
# seeder.seed_respondents sample_districts_and_schools_csv
# end.to change { Respondent.count }.by(School.count)
# end
it 'seeds idempotently' do
expect do
seeder.seed_respondents sample_districts_and_schools_csv
end.to change { Respondent.count }.by(School.count)
# it 'seeds idempotently' do
# expect do
# seeder.seed_respondents sample_districts_and_schools_csv
# end.to change { Respondent.count }.by(School.count)
expect(Respondent.all.count).to eq School.count
# expect(Respondent.all.count).to eq School.count
expect do
seeder.seed_respondents sample_districts_and_schools_csv
end.to change { Respondent.count }.by(0)
end
# expect do
# seeder.seed_respondents sample_districts_and_schools_csv
# end.to change { Respondent.count }.by(0)
# end
it 'seeds new respondents for every year in the database' do
expect do
seeder.seed_respondents sample_districts_and_schools_csv
end.to change { Respondent.count }.by School.count
# it 'seeds new respondents for every year in the database' do
# expect do
# seeder.seed_respondents sample_districts_and_schools_csv
# end.to change { Respondent.count }.by School.count
expect do
create(:academic_year, range: '2019-20')
seeder.seed_respondents sample_districts_and_schools_csv
end.to change { Respondent.count }.by School.count
end
it 'seeds the total number of students and teachers even if the original number includes commas' do
seeder.seed_respondents sample_districts_and_schools_csv
school = School.find_by_name('Attleboro High School')
academic_year = AcademicYear.find_by_range('2020-21')
school_with_over_one_thousand_student_respondents = Respondent.where(school:, academic_year:).first
expect(school_with_over_one_thousand_student_respondents.total_students).to eq 1792
end
end
# expect do
# create(:academic_year, range: '2019-20')
# seeder.seed_respondents sample_districts_and_schools_csv
# end.to change { Respondent.count }.by School.count
# end
# it 'seeds the total number of students and teachers even if the original number includes commas' do
# seeder.seed_respondents sample_districts_and_schools_csv
# school = School.find_by_name('Attleboro High School')
# academic_year = AcademicYear.find_by_range('2020-21')
# school_with_over_one_thousand_student_respondents = Respondent.where(school:, academic_year:).first
# expect(school_with_over_one_thousand_student_respondents.total_students).to eq 1792
# end
# end
context 'surveys' do
before :each do