@ -23,6 +23,7 @@ RSpec.describe SurveyItemValues, type: :model do
create ( :race , qualtrics_code : 7 )
create ( :race , qualtrics_code : 7 )
create ( :race , qualtrics_code : 8 )
create ( :race , qualtrics_code : 8 )
create ( :race , qualtrics_code : 99 )
create ( :race , qualtrics_code : 99 )
create ( :race , qualtrics_code : 100 )
Race . by_qualtrics_code
Race . by_qualtrics_code
end
end
@ -117,7 +118,8 @@ RSpec.describe SurveyItemValues, type: :model do
context " .school " do
context " .school " do
it " returns the school that maps to the dese id provided " do
it " returns the school that maps to the dese id provided " do
attleboro
attleboro
row = { " Dese ID " = > " 1234 " }
headers = [ " DeseID " ]
row = { " DeseID " = > " 1234 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . school ) . to eq attleboro
expect ( values . school ) . to eq attleboro
@ -222,15 +224,15 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 1 " }
row = { " Race " = > " 1 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 ]
row = { " Race " = > " Native American " }
row = { " Race " = > " Native American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 ]
row = { " Race " = > " American Indian or Alaskan Native " }
row = { " Race " = > " American Indian or Alaskan Native " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 ]
end
end
end
end
@ -238,19 +240,19 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 2 " }
row = { " Race " = > " 2 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
row = { " Race " = > " Asian " }
row = { " Race " = > " Asian " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
row = { " Race " = > " Pacific Islander " }
row = { " Race " = > " Pacific Islander " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
row = { " Race " = > " Pacific Island or Hawaiian Native " }
row = { " Race " = > " Pacific Island or Hawaiian Native " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 ]
end
end
end
end
@ -258,15 +260,15 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 3 " }
row = { " Race " = > " 3 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 3 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 3 ]
row = { " Race " = > " Black " }
row = { " Race " = > " Black " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 3 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 3 ]
row = { " Race " = > " African American " }
row = { " Race " = > " African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 3 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 3 ]
end
end
end
end
@ -274,15 +276,15 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 4 " }
row = { " Race " = > " 4 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 4 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 4 ]
row = { " Race " = > " Hispanic " }
row = { " Race " = > " Hispanic " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 4 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 4 ]
row = { " Race " = > " Latinx " }
row = { " Race " = > " Latinx " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 4 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 4 ]
end
end
end
end
@ -290,15 +292,15 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 5 " }
row = { " Race " = > " 5 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 ]
row = { " Race " = > " White " }
row = { " Race " = > " White " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 ]
row = { " Race " = > " Caucasian " }
row = { " Race " = > " Caucasian " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 ]
end
end
end
end
@ -306,11 +308,11 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 6 " }
row = { " Race " = > " 6 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " Prefer not to disclose " }
row = { " Race " = > " Prefer not to disclose " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
end
end
end
end
@ -318,11 +320,11 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 6 " }
row = { " Race " = > " 6 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " Prefer not to disclose " }
row = { " Race " = > " Prefer not to disclose " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
end
end
end
end
@ -330,11 +332,11 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 7 " }
row = { " Race " = > " 7 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " Prefer to self-describe " }
row = { " Race " = > " Prefer to self-describe " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
end
end
end
end
@ -342,15 +344,15 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 8 " }
row = { " Race " = > " 8 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 8 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 8 ]
row = { " Race " = > " Middle Eastern " }
row = { " Race " = > " Middle Eastern " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 8 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 8 ]
row = { " Race " = > " North African " }
row = { " Race " = > " North African " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 8 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 8 ]
end
end
end
end
@ -358,23 +360,66 @@ RSpec.describe SurveyItemValues, type: :model do
it " returns the gender that maps to the gender provided " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " NA " }
row = { " Race " = > " NA " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " # N/A " }
row = { " Race " = > " # N/A " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " n/a " }
row = { " Race " = > " n/a " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " # na " }
row = { " Race " = > " # na " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
row = { " Race " = > " " }
row = { " Race " = > " " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
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
end
end
end
@ -538,15 +583,15 @@ RSpec.describe SurveyItemValues, type: :model do
expect ( values . sped ) . to eq " Not Special Education "
expect ( values . sped ) . to eq " Not Special Education "
end
end
it 'tranlsates NA into " Unknow n"' do
it 'tranlsates NA into " Not Special Educatio n"' do
headers = [ " Raw SpEd " ]
headers = [ " Raw SpEd " ]
row = { " Raw SpEd " = > " NA " }
row = { " Raw SpEd " = > " NA " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
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 " }
row = { " Raw SpEd " = > " # NA " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
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
end
end
@ -668,15 +713,14 @@ RSpec.describe SurveyItemValues, type: :model do
end
end
context " when progress is invalid " do
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
headers = standard_survey_items
row = { " s-peff-q1 " = > 1 , " s-peff-q2 " = > 1 , " s-peff-q3 " = > 1 , " s-peff-q4 " = > 1 ,
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-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-emsa-q3 " = > 1 , " s-sbel-q1 " = > 1 , " s-sbel-q2 " = > 1 , " s-sbel-q3 " = > 1 }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : ,
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : ,
schools : )
schools : )
expect ( values . progress ) . to eq 1 6
expect ( values . progress ) . to eq 1 0
expect ( values . valid_progress? ) . to eq false
expect ( values . valid_progress? ) . to eq false
end
end
@ -722,15 +766,15 @@ RSpec.describe SurveyItemValues, type: :model do
attleboro_respondents
attleboro_respondents
end
end
it " returns true for students " do
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 , " Dese ID" = > " 1234 " } , headers : , genders : , survey_items : ,
values = SurveyItemValues . new ( row : { " grade " = > " 9 " , " RecordedDate " = > recorded_date , " Dese ID" = > " 1234 " } , headers : , genders : , survey_items : ,
schools : )
schools : )
expect ( values . valid_grade? ) . to eq true
expect ( values . valid_grade? ) . to eq true
end
end
it " returns true for teachers " do
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 , " Dese ID" = > " 1234 " } , headers : , genders : , survey_items : ,
values = SurveyItemValues . new ( row : { " RecordedDate " = > recorded_date , " Dese ID" = > " 1234 " } , headers : , genders : , survey_items : ,
schools : )
schools : )
expect ( values . valid_grade? ) . to eq true
expect ( values . valid_grade? ) . to eq true
end
end
@ -742,8 +786,8 @@ RSpec.describe SurveyItemValues, type: :model do
attleboro_respondents
attleboro_respondents
end
end
it " returns false " do
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 , " Dese ID" = > " 1234 " } , headers : , genders : , survey_items : ,
values = SurveyItemValues . new ( row : { " grade " = > " 2 " , " RecordedDate " = > recorded_date , " Dese ID" = > " 1234 " } , headers : , genders : , survey_items : ,
schools : School . school_hash )
schools : School . school_hash )
expect ( values . valid_grade? ) . to eq false
expect ( values . valid_grade? ) . to eq false
end
end