|
|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
require "rails_helper"
|
|
|
|
|
|
|
|
|
|
describe SubcategoryPresenter do
|
|
|
|
|
let(:academic_year) { create(:academic_year, range: '1989-90') }
|
|
|
|
|
let(:school) { create(:school, name: 'Best School') }
|
|
|
|
|
let(:academic_year) { create(:academic_year, range: "1989-90") }
|
|
|
|
|
let(:school) { create(:school, name: "Best School") }
|
|
|
|
|
let(:worst_school) { create(:school, name: "Worst School", dese_id: 2) }
|
|
|
|
|
let(:subcategory) do
|
|
|
|
|
create(:subcategory, name: 'A great subcategory', subcategory_id: 'A', description: 'A great description')
|
|
|
|
|
create(:subcategory, name: "A great subcategory", subcategory_id: "A", description: "A great description")
|
|
|
|
|
end
|
|
|
|
|
let(:measure_of_only_admin_data) { create(:measure, subcategory:) }
|
|
|
|
|
let(:scale_of_only_admin_data) { create(:scale, measure: measure_of_only_admin_data) }
|
|
|
|
|
@ -52,95 +53,95 @@ describe SubcategoryPresenter do
|
|
|
|
|
create(:respondent, school:, academic_year:, one: 40)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the name of the subcategory' do
|
|
|
|
|
expect(subcategory_presenter.name).to eq 'A great subcategory'
|
|
|
|
|
it "returns the name of the subcategory" do
|
|
|
|
|
expect(subcategory_presenter.name).to eq "A great subcategory"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the description of the subcategory' do
|
|
|
|
|
expect(subcategory_presenter.description).to eq 'A great description'
|
|
|
|
|
it "returns the description of the subcategory" do
|
|
|
|
|
expect(subcategory_presenter.description).to eq "A great description"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the id of the subcategory' do
|
|
|
|
|
expect(subcategory_presenter.id).to eq 'A'
|
|
|
|
|
it "returns the id of the subcategory" do
|
|
|
|
|
expect(subcategory_presenter.id).to eq "A"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns a gauge presenter responsible for the aggregate admin data and survey item response likert scores' do
|
|
|
|
|
expect(subcategory_presenter.gauge_presenter.title).to eq 'Growth'
|
|
|
|
|
it "returns a gauge presenter responsible for the aggregate admin data and survey item response likert scores" do
|
|
|
|
|
expect(subcategory_presenter.gauge_presenter.title).to eq "Growth"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the student response rate' do
|
|
|
|
|
expect(subcategory_presenter.student_response_rate).to eq '25%'
|
|
|
|
|
it "returns the student response rate" do
|
|
|
|
|
expect(subcategory_presenter.student_response_rate).to eq "25%"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the teacher response rate' do
|
|
|
|
|
expect(subcategory_presenter.teacher_response_rate).to eq '50%'
|
|
|
|
|
it "returns the teacher response rate" do
|
|
|
|
|
expect(subcategory_presenter.teacher_response_rate).to eq "50%"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the admin collection rate' do
|
|
|
|
|
it "returns the admin collection rate" do
|
|
|
|
|
expect(subcategory_presenter.admin_collection_rate).to eq %w[N A]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'creates a measure presenter for each measure in a subcategory' do
|
|
|
|
|
it "creates a measure presenter for each measure in a subcategory" do
|
|
|
|
|
expect(subcategory_presenter.measure_presenters.count).to eq subcategory.measures.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'When there are no measures populated with student or teacher surveys' do
|
|
|
|
|
context "When there are no measures populated with student or teacher surveys" do
|
|
|
|
|
let(:empty_subcategory) { create :subcategory }
|
|
|
|
|
let(:empty_subcategory_presenter) do
|
|
|
|
|
SubcategoryPresenter.new(subcategory: empty_subcategory, academic_year:, school:)
|
|
|
|
|
end
|
|
|
|
|
it 'should make a subcategory presenter return insufficient data' do
|
|
|
|
|
it "should make a subcategory presenter return insufficient data" do
|
|
|
|
|
expect(empty_subcategory_presenter.subcategory_card_presenter.insufficient_data?).to eq true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create_survey_item_responses_for_different_years_and_schools(survey_item)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item:,
|
|
|
|
|
school: School.new(name: 'Worst School', dese_id: 2), likert_score: 1)
|
|
|
|
|
school: worst_school, likert_score: 1)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item:,
|
|
|
|
|
academic_year: AcademicYear.create(range: '2000-01'), likert_score: 1)
|
|
|
|
|
academic_year: AcademicYear.create(range: "2000-01"), likert_score: 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'When there are admin data items' do
|
|
|
|
|
context 'and the school is not a high school' do
|
|
|
|
|
context 'and the measure does not include high-school-only admin data items' do
|
|
|
|
|
context "When there are admin data items" do
|
|
|
|
|
context "and the school is not a high school" do
|
|
|
|
|
context "and the measure does not include high-school-only admin data items" do
|
|
|
|
|
before do
|
|
|
|
|
measure_of_only_admin_data
|
|
|
|
|
scale_of_only_admin_data
|
|
|
|
|
admin_data_item_1
|
|
|
|
|
admin_data_item_2
|
|
|
|
|
end
|
|
|
|
|
context 'and there are no admin data values in the database' do
|
|
|
|
|
it 'returns the admin collection rate' do
|
|
|
|
|
context "and there are no admin data values in the database" do
|
|
|
|
|
it "returns the admin collection rate" do
|
|
|
|
|
expect(subcategory_presenter.admin_collection_rate).to eq [0, 2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
context 'and there are admin data values present in the database ' do
|
|
|
|
|
context "and there are admin data values present in the database " do
|
|
|
|
|
before do
|
|
|
|
|
create(:admin_data_value, admin_data_item: admin_data_item_1, school:, academic_year:)
|
|
|
|
|
create(:admin_data_value, admin_data_item: admin_data_item_2, school:, academic_year:)
|
|
|
|
|
end
|
|
|
|
|
it 'returns the admin collection rate' do
|
|
|
|
|
it "returns the admin collection rate" do
|
|
|
|
|
expect(subcategory_presenter.admin_collection_rate).to eq [2, 2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'and the measure includes high-school-only items' do
|
|
|
|
|
context "and the measure includes high-school-only items" do
|
|
|
|
|
before do
|
|
|
|
|
measure_of_only_admin_data = create(:measure, subcategory:)
|
|
|
|
|
scale_of_only_admin_data = create(:scale, measure: measure_of_only_admin_data)
|
|
|
|
|
create(:admin_data_item, scale: scale_of_only_admin_data, hs_only_item: true)
|
|
|
|
|
create(:admin_data_item, scale: scale_of_only_admin_data, hs_only_item: true)
|
|
|
|
|
end
|
|
|
|
|
it 'returns the admin collection rate' do
|
|
|
|
|
it "returns the admin collection rate" do
|
|
|
|
|
expect(subcategory_presenter.admin_collection_rate).to eq %w[N A]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'and the school is a high school' do
|
|
|
|
|
context 'and the measure does not include high-school-only admin data items' do
|
|
|
|
|
context "and the school is a high school" do
|
|
|
|
|
context "and the measure does not include high-school-only admin data items" do
|
|
|
|
|
before do
|
|
|
|
|
school.is_hs = true
|
|
|
|
|
school.save
|
|
|
|
|
@ -149,12 +150,12 @@ describe SubcategoryPresenter do
|
|
|
|
|
create(:admin_data_item, scale: scale_of_only_admin_data, hs_only_item: false)
|
|
|
|
|
create(:admin_data_item, scale: scale_of_only_admin_data, hs_only_item: false)
|
|
|
|
|
end
|
|
|
|
|
it 'returns the admin collection rate' do
|
|
|
|
|
it "returns the admin collection rate" do
|
|
|
|
|
expect(subcategory_presenter.admin_collection_rate).to eq [0, 2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'and the measure includes high-school-only items' do
|
|
|
|
|
context "and the measure includes high-school-only items" do
|
|
|
|
|
before do
|
|
|
|
|
school.is_hs = true
|
|
|
|
|
school.save
|
|
|
|
|
@ -163,7 +164,7 @@ describe SubcategoryPresenter do
|
|
|
|
|
create(:admin_data_item, scale: scale_of_only_admin_data, hs_only_item: true)
|
|
|
|
|
create(:admin_data_item, scale: scale_of_only_admin_data, hs_only_item: true)
|
|
|
|
|
end
|
|
|
|
|
it 'returns the admin collection rate' do
|
|
|
|
|
it "returns the admin collection rate" do
|
|
|
|
|
expect(subcategory_presenter.admin_collection_rate).to eq [0, 2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|