mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Split academic year into seasons if the academic year's range is
initialized with a season, i.e. "2024-25 Fall". Update scapers for admin data, enrollment and staffing to use the new range standard correctly. Update the loaders for admin data, enrollment and staffing so that it populates all seasons in a given year. So admin data for 2024-25 gets loaded into "2024-25 Fall" and "2024-25 Spring". Add tests for the new range format. Set the default cutoff for the start of Spring season will be the last Sunday in February
This commit is contained in:
parent
996bb01d0b
commit
33da0859b9
43 changed files with 62404 additions and 28698 deletions
|
|
@ -153,7 +153,7 @@ RSpec.describe Cleaner do
|
|||
survey_items = SurveyItem.where(survey_item_id: standard_survey_items)
|
||||
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: standard_survey_items, survey_items:,
|
||||
schools: School.school_by_dese_id)]
|
||||
schools: School.by_dese_id)]
|
||||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: standard_survey_items, data:, filepath: nil
|
||||
)
|
||||
|
|
@ -165,7 +165,7 @@ RSpec.describe Cleaner do
|
|||
survey_items = SurveyItem.where(survey_item_id: short_form_survey_items)
|
||||
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: short_form_survey_items, survey_items:,
|
||||
schools: School.school_by_dese_id)]
|
||||
schools: School.by_dese_id)]
|
||||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: short_form_survey_items, data:, filepath: nil
|
||||
)
|
||||
|
|
@ -178,7 +178,7 @@ RSpec.describe Cleaner do
|
|||
survey_items = SurveyItem.where(survey_item_id: early_education_survey_items)
|
||||
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:,
|
||||
schools: School.school_by_dese_id)]
|
||||
schools: School.by_dese_id)]
|
||||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: early_education_survey_items, data:, filepath: nil
|
||||
)
|
||||
|
|
@ -190,7 +190,7 @@ RSpec.describe Cleaner do
|
|||
survey_items = SurveyItem.where(survey_item_id: teacher_survey_items)
|
||||
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: teacher_survey_items, survey_items:,
|
||||
schools: School.school_by_dese_id)]
|
||||
schools: School.by_dese_id)]
|
||||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: teacher_survey_items, data:, filepath: nil
|
||||
)
|
||||
|
|
@ -202,9 +202,9 @@ RSpec.describe Cleaner do
|
|||
it "adds all districts to the filename" do
|
||||
survey_items = SurveyItem.where(survey_item_id: teacher_survey_items)
|
||||
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: teacher_survey_items, survey_items:, schools: School.school_by_dese_id),
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: teacher_survey_items, survey_items:, schools: School.by_dese_id),
|
||||
SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "222_222" },
|
||||
headers: teacher_survey_items, survey_items:, schools: School.school_by_dese_id)]
|
||||
headers: teacher_survey_items, survey_items:, schools: School.by_dese_id)]
|
||||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: teacher_survey_items, data:, filepath: nil
|
||||
)
|
||||
|
|
@ -217,7 +217,7 @@ RSpec.describe Cleaner do
|
|||
survey_items = SurveyItem.where(survey_item_id: early_education_survey_items)
|
||||
|
||||
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:,
|
||||
schools: School.school_by_dese_id)]
|
||||
schools: School.by_dese_id)]
|
||||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: early_education_survey_items, data:, filepath: "/data/survey_responses/maynard early ed_ part a.2022-23.csv"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ require "rails_helper"
|
|||
RSpec.describe Dese::Loader do
|
||||
let(:path_to_admin_data) { Rails.root.join("spec", "fixtures", "sample_four_d_data.csv") }
|
||||
|
||||
let(:ay_2023_24_fall) { create(:academic_year, range: "2023-24 Fall") }
|
||||
let(:ay_2023_24_spring) { create(:academic_year, range: "2023-24 Spring") }
|
||||
let(:ay_2022_23) { create(:academic_year, range: "2022-23") }
|
||||
let(:ay_2021_22) { create(:academic_year, range: "2021-22") }
|
||||
let(:ay_2020_21) { create(:academic_year, range: "2020-21") }
|
||||
|
|
@ -17,6 +19,8 @@ RSpec.describe Dese::Loader do
|
|||
let(:next_wave) { create(:school, dese_id: 2_740_510) }
|
||||
|
||||
before :each do
|
||||
ay_2023_24_fall
|
||||
ay_2023_24_spring
|
||||
ay_2022_23
|
||||
ay_2021_22
|
||||
ay_2020_21
|
||||
|
|
@ -32,9 +36,6 @@ RSpec.describe Dese::Loader do
|
|||
next_wave
|
||||
end
|
||||
|
||||
after :each do
|
||||
# DatabaseCleaner.clean
|
||||
end
|
||||
context "when running the loader" do
|
||||
before :each do
|
||||
Dese::Loader.load_data filepath: path_to_admin_data
|
||||
|
|
@ -53,8 +54,30 @@ RSpec.describe Dese::Loader do
|
|||
academic_year: ay_2020_21).likert_score).to eq 4.8
|
||||
end
|
||||
|
||||
it "loads admin data for years that are split into seasons" do
|
||||
academic_year = ay_2023_24_fall
|
||||
expect(AdminDataValue.find_by(school: winchester, admin_data_item: four_d,
|
||||
academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: attleboro, admin_data_item: four_d,
|
||||
academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: milford, admin_data_item: four_d, academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: seacoast, admin_data_item: four_d, academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: next_wave, admin_data_item: four_d,
|
||||
academic_year:).likert_score).to eq 4.44
|
||||
|
||||
academic_year = ay_2023_24_spring
|
||||
expect(AdminDataValue.find_by(school: winchester, admin_data_item: four_d,
|
||||
academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: attleboro, admin_data_item: four_d,
|
||||
academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: milford, admin_data_item: four_d, academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: seacoast, admin_data_item: four_d, academic_year:).likert_score).to eq 4.44
|
||||
expect(AdminDataValue.find_by(school: next_wave, admin_data_item: four_d,
|
||||
academic_year:).likert_score).to eq 4.44
|
||||
end
|
||||
|
||||
it "loads the correct number of items" do
|
||||
expect(AdminDataValue.count).to eq 23
|
||||
expect(AdminDataValue.count).to eq 33
|
||||
end
|
||||
|
||||
it "cap maximum likert score to 5" do
|
||||
|
|
@ -77,7 +100,7 @@ RSpec.describe Dese::Loader do
|
|||
it "is idempotent" do
|
||||
Dese::Loader.load_data filepath: path_to_admin_data
|
||||
|
||||
expect(AdminDataValue.count).to eq 23
|
||||
expect(AdminDataValue.count).to eq 33
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,23 +2,27 @@ require "rails_helper"
|
|||
|
||||
describe EnrollmentLoader do
|
||||
let(:path_to_enrollment_data) { Rails.root.join("spec", "fixtures", "sample_enrollment_data.csv") }
|
||||
let(:ay_2021_22) { create(:academic_year, range: "2021-22") }
|
||||
let(:ay_2022_23) { create(:academic_year, range: "2022-23") }
|
||||
let(:ay_2023_24) { create(:academic_year, range: "2023-24") }
|
||||
let(:ay_2024_25_fall) { create(:academic_year, range: "2024-25 Fall") }
|
||||
let(:ay_2024_25_spring) { create(:academic_year, range: "2024-25 Spring") }
|
||||
|
||||
let(:attleboro) { create(:school, name: "Attleboro", dese_id: 160_505) }
|
||||
let(:beachmont) { create(:school, name: "Beachmont", dese_id: 2_480_013) }
|
||||
let(:winchester) { create(:school, name: "Winchester", dese_id: 3_440_505) }
|
||||
before :each do
|
||||
ay_2021_22
|
||||
ay_2022_23
|
||||
ay_2023_24
|
||||
ay_2024_25_fall
|
||||
ay_2024_25_spring
|
||||
attleboro
|
||||
beachmont
|
||||
winchester
|
||||
EnrollmentLoader.load_data filepath: path_to_enrollment_data
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
context "self.load_data" do
|
||||
it "loads the correct enrollment numbers" do
|
||||
academic_year = ay_2022_23
|
||||
|
|
@ -35,6 +39,109 @@ describe EnrollmentLoader do
|
|||
expect(Respondent.find_by(school: winchester, academic_year:).eleven).to eq 339
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).twelve).to eq 352
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_students).to eq 1383
|
||||
|
||||
academic_year = ay_2021_22
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).nine).to eq 10
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_students).to eq 150
|
||||
# expect(Respondent.find_by(school: attleboro, academic_year:).total_students).to eq 1844
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).pk).to eq 10
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).k).to eq 10
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).one).to eq 10
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_students).to eq 150
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).nine).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).ten).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).eleven).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).twelve).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_students).to eq 150
|
||||
end
|
||||
|
||||
it "does not load numbers for years outside the file given" do
|
||||
academic_year = ay_2023_24
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:)).to eq nil
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:)).to eq nil
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: winchester, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: winchester, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: winchester, academic_year:)).to eq nil
|
||||
expect(Respondent.find_by(school: winchester, academic_year:)).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
context "self.clone_previous_year_data" do
|
||||
before do
|
||||
EnrollmentLoader.clone_previous_year_data
|
||||
end
|
||||
|
||||
it "populates empty data with last known enrollment numbers" do
|
||||
# "2023-24"
|
||||
academic_year = ay_2023_24
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).nine).to eq 506
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).pk).to eq 34
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).k).to eq 64
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).one).to eq 58
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_students).to eq 336
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).nine).to eq 361
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).ten).to eq 331
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).eleven).to eq 339
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).twelve).to eq 352
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_students).to eq 1383
|
||||
|
||||
# "2024-25 Fall"
|
||||
academic_year = ay_2024_25_fall
|
||||
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).nine).to eq 506
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).pk).to eq 34
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).k).to eq 64
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).one).to eq 58
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_students).to eq 336
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).nine).to eq 361
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).ten).to eq 331
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).eleven).to eq 339
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).twelve).to eq 352
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_students).to eq 1383
|
||||
|
||||
# "2024-25 Spring"
|
||||
academic_year = ay_2024_25_spring
|
||||
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).nine).to eq 506
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).pk).to eq 34
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).k).to eq 64
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).one).to eq 58
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_students).to eq 336
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).nine).to eq 361
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).ten).to eq 331
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).eleven).to eq 339
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).twelve).to eq 352
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_students).to eq 1383
|
||||
|
||||
# Anything that already has numbers from the csv files stays the same
|
||||
academic_year = ay_2021_22
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).nine).to eq 10
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_students).to eq 150
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).pk).to eq 10
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).k).to eq 10
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).one).to eq 10
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_students).to eq 150
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).nine).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).ten).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).eleven).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).twelve).to eq 10
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_students).to eq 150
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,27 +2,30 @@ require "rails_helper"
|
|||
|
||||
describe StaffingLoader do
|
||||
let(:path_to_staffing_data) { Rails.root.join("spec", "fixtures", "sample_staffing_data.csv") }
|
||||
let(:ay_2022_23) { create(:academic_year, range: "2022-23") }
|
||||
let(:ay_2020_21) { create(:academic_year, range: "2020-21") }
|
||||
let(:ay_2021_22) { create(:academic_year, range: "2021-22") }
|
||||
let(:ay_2022_23) { create(:academic_year, range: "2022-23") }
|
||||
let(:ay_2023_24_fall) { create(:academic_year, range: "2023-24 Fall") }
|
||||
let(:ay_2023_24_spring) { create(:academic_year, range: "2023-24 Spring") }
|
||||
let(:attleboro) { create(:school, name: "Attleboro", dese_id: 160_505) }
|
||||
let(:beachmont) { create(:school, name: "Beachmont", dese_id: 2_480_013) }
|
||||
let(:winchester) { create(:school, name: "Winchester", dese_id: 3_440_505) }
|
||||
|
||||
before :each do
|
||||
ay_2022_23
|
||||
ay_2020_21
|
||||
ay_2021_22
|
||||
ay_2022_23
|
||||
ay_2023_24_fall
|
||||
ay_2023_24_spring
|
||||
attleboro
|
||||
beachmont
|
||||
winchester
|
||||
StaffingLoader.load_data filepath: path_to_staffing_data
|
||||
StaffingLoader.clone_previous_year_data
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
context "self.load_data" do
|
||||
before do
|
||||
StaffingLoader.load_data filepath: path_to_staffing_data
|
||||
end
|
||||
it "loads the correct staffing numbers" do
|
||||
academic_year = ay_2021_22
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
|
|
@ -31,19 +34,44 @@ describe StaffingLoader do
|
|||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 149.8
|
||||
end
|
||||
end
|
||||
|
||||
context "when the staffing data is missing a school" do
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
it "fills in empty staffing numbers with the previous years data" do
|
||||
academic_year = ay_2022_23
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
context "self.clone_previous_year_data" do
|
||||
before do
|
||||
StaffingLoader.load_data filepath: path_to_staffing_data
|
||||
StaffingLoader.clone_previous_year_data
|
||||
end
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_teachers).to eq 56.4
|
||||
it "fills in empty staffing numbers with the previous years data" do
|
||||
academic_year = ay_2022_23
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 149.8
|
||||
end
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_teachers).to eq 56.4
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 149.8
|
||||
|
||||
academic_year = ay_2023_24_fall
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_teachers).to eq 56.4
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 149.8
|
||||
|
||||
academic_year = ay_2023_24_spring
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_teachers).to eq 56.4
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 149.8
|
||||
|
||||
# Does not touch existing numbers
|
||||
|
||||
academic_year = ay_2020_21
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 100
|
||||
|
||||
expect(Respondent.find_by(school: beachmont, academic_year:).total_teachers).to eq 100
|
||||
|
||||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -35,11 +35,12 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
let(:attleboro_respondents) do
|
||||
create(:respondent, school: attleboro, academic_year: ay_2022_23, nine: 40, ten: 40, eleven: 40, twelve: 40)
|
||||
end
|
||||
let(:schools) { School.school_by_dese_id }
|
||||
let(:schools) { School.by_dese_id }
|
||||
let(:recorded_date) { "2023-04-01T12:12:12" }
|
||||
let(:ay_2022_23) do
|
||||
create(:academic_year, range: "2022-23")
|
||||
end
|
||||
let(:academic_years) { AcademicYear.all }
|
||||
|
||||
let(:common_headers) do
|
||||
["Recorded Date", "DeseID", "ResponseID", "Duration (in seconds)", "Gender", "Grade"]
|
||||
|
|
@ -105,12 +106,12 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context ".recorded_date" do
|
||||
it "returns the recorded date" do
|
||||
row = { "RecordedDate" => "2017-01-01T12:12:121" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.recorded_date).to eq Date.parse("2017-01-01T12:12:12")
|
||||
|
||||
headers = ["Recorded Date"]
|
||||
row = { "Recorded Date" => "2017-01-02T12:12:122" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.recorded_date).to eq Date.parse("2017-01-02T12:12:12")
|
||||
end
|
||||
end
|
||||
|
|
@ -120,11 +121,11 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
attleboro
|
||||
headers = ["DeseID"]
|
||||
row = { "DeseID" => "1234" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.school).to eq attleboro
|
||||
|
||||
row = { "DeseID" => "1234" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.school).to eq attleboro
|
||||
end
|
||||
end
|
||||
|
|
@ -132,7 +133,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context ".grade" do
|
||||
it "returns the grade that maps to the grade provided" do
|
||||
row = { "Grade" => "1" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.grade).to eq 1
|
||||
end
|
||||
end
|
||||
|
|
@ -141,15 +142,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the gender is female" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Gender" => "1" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 1
|
||||
|
||||
row = { "Gender" => "Female" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 1
|
||||
|
||||
row = { "Gender" => "F" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 1
|
||||
end
|
||||
end
|
||||
|
|
@ -157,15 +158,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the gender is male" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Gender" => "2" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 2
|
||||
|
||||
row = { "Gender" => "Male" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 2
|
||||
|
||||
row = { "Gender" => "M" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 2
|
||||
end
|
||||
end
|
||||
|
|
@ -173,15 +174,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the gender is non-binary" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Gender" => "4" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 4
|
||||
|
||||
row = { "Gender" => "N - Non-Binary" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 4
|
||||
|
||||
row = { "Gender" => "N" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 4
|
||||
end
|
||||
end
|
||||
|
|
@ -189,27 +190,27 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the gender is not known" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Gender" => "N/A" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 99
|
||||
|
||||
row = { "Gender" => "NA" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 99
|
||||
|
||||
row = { "Gender" => "#N/A" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 99
|
||||
|
||||
row = { "Gender" => "#NA" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 99
|
||||
|
||||
row = { "Gender" => "Prefer not to disclose" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 99
|
||||
|
||||
row = { "Gender" => "" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.gender).to eq 99
|
||||
end
|
||||
end
|
||||
|
|
@ -223,15 +224,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is Native American" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "1" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1]
|
||||
|
||||
row = { "Race" => "Native American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1]
|
||||
|
||||
row = { "Race" => "American Indian or Alaskan Native" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1]
|
||||
end
|
||||
end
|
||||
|
|
@ -239,19 +240,19 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is Asian" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "2" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [2]
|
||||
|
||||
row = { "Race" => "Asian" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [2]
|
||||
|
||||
row = { "Race" => "Pacific Islander" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [2]
|
||||
|
||||
row = { "Race" => "Pacific Island or Hawaiian Native" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [2]
|
||||
end
|
||||
end
|
||||
|
|
@ -259,15 +260,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is Black" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "3" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [3]
|
||||
|
||||
row = { "Race" => "Black" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [3]
|
||||
|
||||
row = { "Race" => "African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [3]
|
||||
end
|
||||
end
|
||||
|
|
@ -275,15 +276,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is Hispanic" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "4" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [4]
|
||||
|
||||
row = { "Race" => "Hispanic" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [4]
|
||||
|
||||
row = { "Race" => "Latinx" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [4]
|
||||
end
|
||||
end
|
||||
|
|
@ -291,15 +292,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is White" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "5" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [5]
|
||||
|
||||
row = { "Race" => "White" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [5]
|
||||
|
||||
row = { "Race" => "Caucasian" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [5]
|
||||
end
|
||||
end
|
||||
|
|
@ -307,11 +308,11 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is not disclosed" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "6" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "Prefer not to disclose" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
end
|
||||
end
|
||||
|
|
@ -319,11 +320,11 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is not disclosed" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "6" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "Prefer not to disclose" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
end
|
||||
end
|
||||
|
|
@ -331,11 +332,11 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is self described" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "7" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "Prefer to self-describe" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
end
|
||||
end
|
||||
|
|
@ -343,15 +344,15 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is Middle Eastern" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "8" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [8]
|
||||
|
||||
row = { "Race" => "Middle Eastern" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [8]
|
||||
|
||||
row = { "Race" => "North African" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [8]
|
||||
end
|
||||
end
|
||||
|
|
@ -359,23 +360,23 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when the race is unknown" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "NA" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "#N/A" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "n/a" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "#na" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
|
||||
row = { "Race" => "" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [99]
|
||||
end
|
||||
end
|
||||
|
|
@ -383,42 +384,42 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when there are multiple races" do
|
||||
it "returns the gender that maps to the gender provided" do
|
||||
row = { "Race" => "1,2,3" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1, 2, 3, 100]
|
||||
|
||||
row = { "Race" => "Alaskan Native, Pacific Islander, Black" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1, 2, 3, 100]
|
||||
|
||||
row = { "Race" => "American Indian or Alaskan Native, Asian, African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1, 2, 3, 100]
|
||||
row = { "Race" => "n/a" }
|
||||
|
||||
row = { "Race" => "American Indian or Alaskan Native, Asian and African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1, 2, 3, 100]
|
||||
|
||||
row = { "Race" => "American Indian or Alaskan Native and Asian and African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1, 2, 3, 100]
|
||||
|
||||
row = { "Race" => "American Indian or Alaskan Native and Asian, and African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [1, 2, 3, 100]
|
||||
|
||||
row = { "Race" => "Asian, Caucasian and African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [2, 5, 3, 100]
|
||||
|
||||
row = { "Race" => "Caucasian and Asian and African American" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [5, 2, 3, 100]
|
||||
|
||||
row = { "Race- SIS" => "Caucasian and Asian and African American", "HispanicLatino" => "true" }
|
||||
headers.push("HispanicLatino")
|
||||
headers.push("Race- SIS")
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.races).to eq [5, 2, 3, 4, 100]
|
||||
end
|
||||
end
|
||||
|
|
@ -427,11 +428,11 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context ".respondent_type" do
|
||||
it "reads header to find the survey type" do
|
||||
headers = %w[s-sbel-q5 s-phys-q2 RecordedDate]
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.respondent_type).to eq :student
|
||||
|
||||
headers = %w[t-sbel-q5 t-phys-q2]
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.respondent_type).to eq :teacher
|
||||
end
|
||||
end
|
||||
|
|
@ -440,14 +441,14 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when survey type is standard form" do
|
||||
it "returns the survey type" do
|
||||
headers = standard_survey_items
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.survey_type).to eq :standard
|
||||
end
|
||||
end
|
||||
context "when survey type is teacher form" do
|
||||
it "returns the survey type" do
|
||||
headers = teacher_survey_items
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.survey_type).to eq :teacher
|
||||
end
|
||||
end
|
||||
|
|
@ -455,7 +456,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when survey type is short form" do
|
||||
it "returns the survey type" do
|
||||
headers = short_form_survey_items
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.survey_type).to eq :short_form
|
||||
end
|
||||
end
|
||||
|
|
@ -463,7 +464,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
context "when survey type is early education" do
|
||||
it "returns the survey type" do
|
||||
headers = early_education_survey_items
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row: {}, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.survey_type).to eq :early_education
|
||||
end
|
||||
end
|
||||
|
|
@ -478,14 +479,14 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "translates Free Lunch to Economically Disadvantaged - Y" do
|
||||
headers = ["LowIncome"]
|
||||
row = { "LowIncome" => "Free Lunch" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.income).to eq "Economically Disadvantaged - Y"
|
||||
end
|
||||
|
||||
it "translates Reduced Lunch to Economically Disadvantaged - Y" do
|
||||
headers = ["LowIncome"]
|
||||
row = { "LowIncome" => "Reduced Lunch" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.income).to eq "Economically Disadvantaged - Y"
|
||||
end
|
||||
|
||||
|
|
@ -493,14 +494,14 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
headers = ["LowIncome"]
|
||||
row = { "LowIncome" => "LowIncome" }
|
||||
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.income).to eq "Economically Disadvantaged - Y"
|
||||
end
|
||||
|
||||
it "translates Not Eligible to Economically Disadvantaged - N" do
|
||||
headers = ["LowIncome"]
|
||||
row = { "LowIncome" => "Not Eligible" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.income).to eq "Economically Disadvantaged - N"
|
||||
end
|
||||
|
||||
|
|
@ -508,7 +509,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
headers = ["LowIncome"]
|
||||
row = { "LowIncome" => "" }
|
||||
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.income).to eq "Unknown"
|
||||
end
|
||||
end
|
||||
|
|
@ -522,37 +523,37 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it 'translates "LEP Student 1st Year" or "LEP Student Not 1st Year" into ELL' do
|
||||
headers = ["Raw ELL"]
|
||||
row = { "Raw ELL" => "LEP Student 1st Year" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "ELL"
|
||||
|
||||
row = { "Raw ELL" => "LEP Student Not 1st Year" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "ELL"
|
||||
|
||||
row = { "Raw ELL" => "LEP Student Not 1st Year" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "ELL"
|
||||
end
|
||||
|
||||
it 'translates "Does not Apply" into "Not ELL"' do
|
||||
headers = ["Raw ELL"]
|
||||
row = { "Raw ELL" => "Does not apply" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "Not ELL"
|
||||
|
||||
row = { "Raw ELL" => "Does Not APPLY" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "Not ELL"
|
||||
end
|
||||
|
||||
it 'tranlsates blanks into "Not Ell"' do
|
||||
headers = ["Raw ELL"]
|
||||
row = { "Raw ELL" => "" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "Not ELL"
|
||||
|
||||
row = { "Raw ELL" => "Anything else" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.ell).to eq "Not ELL"
|
||||
end
|
||||
end
|
||||
|
|
@ -566,32 +567,32 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it 'translates "active" into "Special Education"' do
|
||||
headers = ["Raw SpEd"]
|
||||
row = { "Raw SpEd" => "active" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.sped).to eq "Special Education"
|
||||
end
|
||||
|
||||
it 'translates "exited" into "Not Special Education"' do
|
||||
headers = ["Raw SpEd"]
|
||||
row = { "Raw SpEd" => "exited" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.sped).to eq "Not Special Education"
|
||||
end
|
||||
|
||||
it 'translates blanks into "Not Special Education' do
|
||||
headers = ["Raw SpEd"]
|
||||
row = { "Raw SpEd" => "" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.sped).to eq "Not Special Education"
|
||||
end
|
||||
|
||||
it 'tranlsates NA into "Not Special Education"' do
|
||||
headers = ["Raw SpEd"]
|
||||
row = { "Raw SpEd" => "NA" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.sped).to eq "Not Special Education"
|
||||
|
||||
row = { "Raw SpEd" => "#NA" }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.sped).to eq "Not Special Education"
|
||||
end
|
||||
end
|
||||
|
|
@ -601,33 +602,33 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "returns true" do
|
||||
headers = standard_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "240", "Gender" => "Male" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq true
|
||||
|
||||
headers = teacher_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "300" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq true
|
||||
|
||||
headers = short_form_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "100" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq true
|
||||
|
||||
# When duration is blank or N/A or NA, we don't have enough information to kick out the row as invalid so we keep it in
|
||||
headers = short_form_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq true
|
||||
|
||||
headers = short_form_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "N/A" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq true
|
||||
|
||||
headers = short_form_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "NA" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq true
|
||||
end
|
||||
end
|
||||
|
|
@ -636,16 +637,16 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "returns false" do
|
||||
headers = standard_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "239" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq false
|
||||
|
||||
headers = teacher_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "299" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq false
|
||||
headers = short_form_survey_items
|
||||
values = SurveyItemValues.new(row: { "Duration (in seconds)" => "99" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_duration?).to eq false
|
||||
end
|
||||
end
|
||||
|
|
@ -657,7 +658,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1,
|
||||
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
|
||||
"s-phys-q3" => 1, "s-phys-q4" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:)
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:, schools:, academic_years:)
|
||||
expect(values.progress).to eq 10
|
||||
end
|
||||
end
|
||||
|
|
@ -672,7 +673,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
"s-emsa-q3" => 1, "s-sbel-q1" => 1, "s-sbel-q2" => 1, "s-sbel-q3" => 1,
|
||||
"s-sbel-q4" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 17
|
||||
expect(values.valid_progress?).to eq true
|
||||
end
|
||||
|
|
@ -687,7 +688,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
"t-psup-q3" => 1, "t-psup-q4" => 1, "t-acch-q1" => 1, "t-acch-q2" => 1
|
||||
}
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 12
|
||||
expect(values.valid_progress?).to eq true
|
||||
end
|
||||
|
|
@ -697,7 +698,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1,
|
||||
"s-sbel-q4" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 5
|
||||
expect(values.valid_progress?).to eq true
|
||||
end
|
||||
|
|
@ -707,7 +708,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
row = { "s-peff-es1" => 1, "s-peff-es2" => 1, "s-peff-es3" => 1, "s-peff-es4" => 1,
|
||||
"s-peff-es5" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 5
|
||||
expect(values.valid_progress?).to eq true
|
||||
end
|
||||
|
|
@ -720,7 +721,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
"s-peff-q5" => 1, "s-peff-q6" => 1, "s-phys-q1" => 1, "s-phys-q2" => 1,
|
||||
"s-emsa-q3" => 1, "s-sbel-q1" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 10
|
||||
expect(values.valid_progress?).to eq false
|
||||
end
|
||||
|
|
@ -735,7 +736,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
"t-psup-q3" => 1, "t-psup-q4" => 1, "t-acch-q1" => 1
|
||||
}
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 11
|
||||
expect(values.valid_progress?).to eq false
|
||||
end
|
||||
|
|
@ -744,7 +745,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
headers = short_form_survey_items
|
||||
row = { "s-peff-q1" => 1, "s-peff-q2" => 1, "s-peff-q3" => 1, "s-peff-q4" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 4
|
||||
expect(values.valid_progress?).to eq false
|
||||
end
|
||||
|
|
@ -753,7 +754,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
headers = early_education_survey_items
|
||||
row = { "s-peff-es1" => 1, "s-peff-es2" => 1, "s-peff-es3" => 1, "s-peff-es4" => 1 }
|
||||
values = SurveyItemValues.new(row:, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.progress).to eq 4
|
||||
expect(values.valid_progress?).to eq false
|
||||
end
|
||||
|
|
@ -769,14 +770,14 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "returns true for students" do
|
||||
headers = %w[s-sbel-q5 s-phys-q2 grade RecordedDate DeseID]
|
||||
values = SurveyItemValues.new(row: { "grade" => "9", "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
|
||||
expect(values.valid_grade?).to eq true
|
||||
end
|
||||
it "returns true for teachers" do
|
||||
headers = %w[t-sbel-q5 t-phys-q2 grade RecordedDate DeseID]
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
expect(values.valid_grade?).to eq true
|
||||
end
|
||||
end
|
||||
|
|
@ -789,7 +790,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "returns false" do
|
||||
headers = %w[s-sbel-q5 s-phys-q2 grade RecordedDate DeseID]
|
||||
values = SurveyItemValues.new(row: { "grade" => "2", "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
|
||||
schools: School.school_by_dese_id)
|
||||
schools: School.by_dese_id)
|
||||
expect(values.valid_grade?).to eq false
|
||||
end
|
||||
end
|
||||
|
|
@ -800,13 +801,13 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "returns true for student questions" do
|
||||
headers = %w[s-sbel-q5 s-phys-q1 s-phys-q2 RecordedDate]
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "s-sbel-q5" => "1", "s-phys-q1" => "", "s-phys-q2" => "5" }, headers:, survey_items:,
|
||||
schools: School.school_by_dese_id)
|
||||
schools: School.by_dese_id)
|
||||
expect(values.valid_sd?).to eq true
|
||||
end
|
||||
it "returns true for teacher questions" do
|
||||
headers = %w[t-sbel-q5 t-phys-q2]
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "t-sbel-q5" => "1", "t-phys-q2" => "5" }, headers:, survey_items:,
|
||||
schools: School.school_by_dese_id)
|
||||
schools: School.by_dese_id)
|
||||
expect(values.valid_sd?).to eq true
|
||||
end
|
||||
end
|
||||
|
|
@ -815,13 +816,13 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "returns false for student questions" do
|
||||
headers = %w[s-sbel-q5 s-phys-q1 s-phys-q2 RecordedDate]
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "s-sbel-q5" => "1", "s-phys-q2" => "1" }, headers:, survey_items:,
|
||||
schools: School.school_by_dese_id)
|
||||
schools: School.by_dese_id)
|
||||
expect(values.valid_sd?).to eq false
|
||||
end
|
||||
it "returns false for teacher questions" do
|
||||
headers = %w[t-sbel-q5 t-phys-q1 t-phys-q2 RecordedDate]
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "Dese ID" => "1234", "t-sbel-q5" => "1", "t-phys-q2" => "1" }, headers:, survey_items:,
|
||||
schools: School.school_by_dese_id)
|
||||
schools: School.by_dese_id)
|
||||
expect(values.valid_sd?).to eq false
|
||||
end
|
||||
end
|
||||
|
|
@ -836,7 +837,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "parses the date correctly when the date is in standard date format for google sheets: 'MM/DD/YYYY HH:MM:SS'" do
|
||||
recorded_date = "1/10/2022 14:21:45"
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
ay_21_22 = AcademicYear.find_by_range "2021-22"
|
||||
expect(values.academic_year).to eq ay_21_22
|
||||
end
|
||||
|
|
@ -844,7 +845,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "parses the date correctly when the date is in iso standard 8601 'YYYY-MM-DDTHH:MM:SS'" do
|
||||
recorded_date = "2022-1-10T14:21:45"
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
ay_21_22 = AcademicYear.find_by_range "2021-22"
|
||||
expect(values.academic_year).to eq ay_21_22
|
||||
end
|
||||
|
|
@ -852,7 +853,7 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
it "parses the date correctly when the date is in the format of: 'YYYY-MM-DD HH:MM:SS'" do
|
||||
recorded_date = "2022-01-10 14:21:45"
|
||||
values = SurveyItemValues.new(row: { "RecordedDate" => recorded_date, "DeseID" => "1234" }, headers:, survey_items:,
|
||||
schools:)
|
||||
schools:, academic_years:)
|
||||
ay_21_22 = AcademicYear.find_by_range "2021-22"
|
||||
expect(values.academic_year).to eq ay_21_22
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue