update response_date to recorded_date

mciea-main
rebuilt 3 years ago
parent d031179dc0
commit f749b96006

@ -13,15 +13,15 @@ class SurveyItemValues
dese_id.present? dese_id.present?
end end
def response_date def recorded_date
@response_date ||= begin @recorded_date ||= begin
recorded_date = value_from(pattern: /Recorded\s*Date/i) recorded_date = value_from(pattern: /Recorded\s*Date/i)
Date.parse(recorded_date) Date.parse(recorded_date)
end end
end end
def academic_year def academic_year
@academic_year ||= AcademicYear.find_by_date response_date @academic_year ||= AcademicYear.find_by_date recorded_date
end end
def survey_item_response(survey_item:) def survey_item_response(survey_item:)

@ -102,7 +102,7 @@ RSpec.describe Cleaner do
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename( filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: standard_survey_items, data: headers: standard_survey_items, data:
) )
expect(filename).to eq 'District1.standard.2022-23.csv' expect(filename).to eq 'district1.standard.2022-23.csv'
end end
context 'when the file is based on short form survey items' do context 'when the file is based on short form survey items' do
@ -114,7 +114,7 @@ RSpec.describe Cleaner do
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename( filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: short_form_survey_items, data: headers: short_form_survey_items, data:
) )
expect(filename).to eq 'District1.short_form.2022-23.csv' expect(filename).to eq 'district1.short_form.2022-23.csv'
end end
end end
@ -127,7 +127,7 @@ RSpec.describe Cleaner do
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename( filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: early_education_survey_items, data: headers: early_education_survey_items, data:
) )
expect(filename).to eq 'District1.early_education.2022-23.csv' expect(filename).to eq 'district1.early_education.2022-23.csv'
end end
end end
context 'when the file is based on teacher survey items' do context 'when the file is based on teacher survey items' do
@ -139,7 +139,7 @@ RSpec.describe Cleaner do
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename( filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: teacher_survey_items, data: headers: teacher_survey_items, data:
) )
expect(filename).to eq 'District1.teacher.2022-23.csv' expect(filename).to eq 'district1.teacher.2022-23.csv'
end end
end end
@ -153,7 +153,7 @@ RSpec.describe Cleaner do
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename( filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: teacher_survey_items, data: headers: teacher_survey_items, data:
) )
expect(filename).to eq 'District1.District2.teacher.2022-23.csv' expect(filename).to eq 'district1.district2.teacher.2022-23.csv'
end end
end end
end end

@ -85,7 +85,12 @@ RSpec.describe SurveyItemValues, type: :model do
it 'returns the recorded date' do it 'returns the recorded date' do
row = { 'RecordedDate' => '2017-01-01' } row = { 'RecordedDate' => '2017-01-01' }
values = SurveyItemValues.new(row:, headers:, genders:, survey_items:, schools:) values = SurveyItemValues.new(row:, headers:, genders:, survey_items:, schools:)
expect(values.response_date).to eq Date.parse('2017-01-01') expect(values.recorded_date).to eq Date.parse('2017-01-01')
headers = ['Recorded Date']
row = { 'Recorded Date' => '2017-01-02' }
values = SurveyItemValues.new(row:, headers:, genders:, survey_items:, schools:)
expect(values.recorded_date).to eq Date.parse('2017-01-02')
end end
end end

Loading…
Cancel
Save