diff --git a/spec/models/measure_spec.rb b/spec/models/measure_spec.rb index 6c5a5361..daa9f8c2 100644 --- a/spec/models/measure_spec.rb +++ b/spec/models/measure_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Measure, type: :model do let(:student_scale) { create(:student_scale, measure:) } let(:admin_scale) { create(:admin_scale, measure:) } let(:school) { create(:school) } + let(:short_form_school){ create(:school)} let(:academic_year) { create(:academic_year) } let(:admin_watch_low_benchmark) { 2.0 } @@ -27,6 +28,8 @@ RSpec.describe Measure, type: :model do before do create(:respondent, school:, academic_year:) create(:survey, school:, academic_year:) + create(:respondent, school: short_form_school, academic_year:) + create(:survey, school: short_form_school, academic_year:, form: "short") end describe 'benchmarks' do @@ -282,6 +285,9 @@ RSpec.describe Measure, type: :model do let(:student_survey_item_1) { create(:student_survey_item, scale: student_scale) } let(:student_survey_item_2) { create(:student_survey_item, scale: student_scale) } let(:student_survey_item_3) { create(:student_survey_item, scale: student_scale) } + let(:short_form_student_survey_item_1) { create(:student_survey_item, scale: student_scale, on_short_form: true) } + let(:short_form_student_survey_item_2) { create(:student_survey_item, scale: student_scale, on_short_form: true) } + let(:short_form_student_survey_item_3) { create(:student_survey_item, scale: student_scale, on_short_form: true) } context "and the number of responses for each of the measure's survey items meets the student threshold " do before :each do @@ -358,6 +364,27 @@ RSpec.describe Measure, type: :model do expect(measure.score(school:, academic_year:).meets_student_threshold?).to be false end end + + context "and the school is a short form school" do + before :each do + create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, + survey_item: student_survey_item_1, academic_year:, school: short_form_school, likert_score: 1) + create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, + survey_item: student_survey_item_2, academic_year:, school: short_form_school, likert_score: 1) + create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, + survey_item: student_survey_item_3, academic_year:, school: short_form_school, likert_score: 1) + create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, + survey_item: short_form_student_survey_item_1, academic_year:, school: short_form_school, likert_score: 3) + create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, + survey_item: short_form_student_survey_item_2, academic_year:, school: short_form_school, likert_score: 4) + create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, + survey_item: short_form_student_survey_item_3, academic_year:, school: short_form_school, likert_score: 5) + end + + it 'ignores any responses not on the short form and gives the average of short form survey items' do + expect(measure.score(school: short_form_school, academic_year:).average).to eq 4 + end + end end context 'when the measure includes both teacher and student data' do diff --git a/spec/system/sqm_application_spec.rb b/spec/system/sqm_application_spec.rb index 8cb6cdc1..2cdab2de 100644 --- a/spec/system/sqm_application_spec.rb +++ b/spec/system/sqm_application_spec.rb @@ -7,12 +7,15 @@ describe 'SQM Application' do let(:category) { create(:category) } let(:measure) { create(:measure) } let(:scale) { create(:teacher_scale, measure:) } + let(:subcategory) { create(:subcategory) } before :each do driven_by :rack_test page.driver.browser.basic_authorize(username, password) create(:respondent, school:, academic_year:) create(:survey, school:, academic_year:) + ResponseRate.create!(subcategory:, school:, academic_year:, + student_response_rate: 0, teacher_response_rate: 0, meets_student_threshold: false, meets_teacher_threshold: false) end context 'when no measures meet their threshold' do diff --git a/spec/views/overview/index.html.erb_spec.rb b/spec/views/overview/index.html.erb_spec.rb index 2fd00a8d..9247101a 100644 --- a/spec/views/overview/index.html.erb_spec.rb +++ b/spec/views/overview/index.html.erb_spec.rb @@ -48,6 +48,9 @@ describe 'overview/index' do @district = create(:district) @school = create(:school) + ResponseRate.create!(subcategory: Subcategory.first, school: @school, academic_year: @academic_year, + student_response_rate: 100, teacher_response_rate: 100, meets_student_threshold: true, meets_teacher_threshold: true) + render end