@ -23,6 +23,7 @@ RSpec.describe SurveyItemValues, type: :model do
create ( :race , qualtrics_code : 7 )
create ( :race , qualtrics_code : 8 )
create ( :race , qualtrics_code : 99 )
create ( :race , qualtrics_code : 100 )
Race . by_qualtrics_code
end
@ -117,6 +118,7 @@ RSpec.describe SurveyItemValues, type: :model do
context " .school " do
it " returns the school that maps to the dese id provided " do
attleboro
headers = [ " DeseID " ]
row = { " DeseID " = > " 1234 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . school ) . to eq attleboro
@ -377,6 +379,49 @@ RSpec.describe SurveyItemValues, type: :model do
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
end
end
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 : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " Alaskan Native, Pacific Islander, Black " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " American Indian or Alaskan Native, Asian, African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . 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 : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " American Indian or Alaskan Native and Asian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " American Indian or Alaskan Native and Asian, and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " Asian, Caucasian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 , 5 , 3 , 100 ]
row = { " Race " = > " Caucasian and Asian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . 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 : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 , 2 , 3 , 4 , 100 ]
end
end
end
context " .respondent_type " do
@ -538,15 +583,15 @@ RSpec.describe SurveyItemValues, type: :model do
expect ( values . sped ) . to eq " Not Special Education "
end
it 'tranlsates NA into " Unknow n"' do
it 'tranlsates NA into " Not Special Educatio n"' do
headers = [ " Raw SpEd " ]
row = { " Raw SpEd " = > " NA " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . sped ) . to eq " Unknow n"
expect ( values . sped ) . to eq " Not Special Educatio n"
row = { " Raw SpEd " = > " # NA " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . sped ) . to eq " Unknow n"
expect ( values . sped ) . to eq " Not Special Educatio n"
end
end
@ -668,15 +713,14 @@ RSpec.describe SurveyItemValues, type: :model do
end
context " when progress is invalid " do
it " when there are fewer than 1 7 standard survey items valid_progress returns true" do
it " when there are fewer than 1 1 standard survey items valid_progress returns true" do
headers = standard_survey_items
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 , " s-emsa-q1 " = > 1 , " s-emsa-q2 " = > 1 ,
" s-emsa-q3 " = > 1 , " s-sbel-q1 " = > 1 , " s-sbel-q2 " = > 1 , " s-sbel-q3 " = > 1 }
" s-emsa-q3 " = > 1 , " s-sbel-q1 " = > 1 }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : ,
schools : )
expect ( values . progress ) . to eq 1 6
expect ( values . progress ) . to eq 1 0
expect ( values . valid_progress? ) . to eq false
end
@ -722,14 +766,14 @@ RSpec.describe SurveyItemValues, type: :model do
attleboro_respondents
end
it " returns true for students " do
headers = %w[ s-sbel-q5 s-phys-q2 grade RecordedDate ]
headers = %w[ s-sbel-q5 s-phys-q2 grade RecordedDate DeseID ]
values = SurveyItemValues . new ( row : { " grade " = > " 9 " , " RecordedDate " = > recorded_date , " DeseID " = > " 1234 " } , headers : , genders : , survey_items : ,
schools : )
expect ( values . valid_grade? ) . to eq true
end
it " returns true for teachers " do
headers = %w[ t-sbel-q5 t-phys-q2 grade RecordedDate ]
headers = %w[ t-sbel-q5 t-phys-q2 grade RecordedDate DeseID ]
values = SurveyItemValues . new ( row : { " RecordedDate " = > recorded_date , " DeseID " = > " 1234 " } , headers : , genders : , survey_items : ,
schools : )
expect ( values . valid_grade? ) . to eq true
@ -742,7 +786,7 @@ RSpec.describe SurveyItemValues, type: :model do
attleboro_respondents
end
it " returns false " do
headers = %w[ s-sbel-q5 s-phys-q2 grade RecordedDate ]
headers = %w[ s-sbel-q5 s-phys-q2 grade RecordedDate DeseID ]
values = SurveyItemValues . new ( row : { " grade " = > " 2 " , " RecordedDate " = > recorded_date , " DeseID " = > " 1234 " } , headers : , genders : , survey_items : ,
schools : School . school_hash )
expect ( values . valid_grade? ) . to eq false