mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-10 07:50:33 -07:00
chore: upgrade to rails 7.1.
upgrade rspec fix failing tests upgrade devise
This commit is contained in:
parent
2fd56047d4
commit
18ab51c860
12 changed files with 268 additions and 238 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require File.expand_path('../config/environment', __dir__)
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require File.expand_path("../config/environment", __dir__)
|
||||
# Prevent database truncation if the environment is production
|
||||
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
||||
require 'spec_helper'
|
||||
require 'rspec/rails'
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
||||
require "spec_helper"
|
||||
require "rspec/rails"
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
# Add additional requires below this line. Rails is not loaded until this point!
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||
|
|
@ -27,7 +27,7 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|||
# If you are not using ActiveRecord, you can remove this line.
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
require 'database_cleaner/active_record'
|
||||
require "database_cleaner/active_record"
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe EnrollmentLoader do
|
||||
let(:path_to_enrollment_data) { Rails.root.join('spec', 'fixtures', 'sample_enrollment_data.csv') }
|
||||
let(:ay_2022_23) { create(:academic_year, range: '2022-23') }
|
||||
let(:path_to_enrollment_data) { Rails.root.join("spec", "fixtures", "sample_enrollment_data.csv") }
|
||||
let(:ay_2022_23) { create(:academic_year, range: "2022-23") }
|
||||
|
||||
let(:attleboro) { School.find_or_create_by(name: 'Attleboro', dese_id: 160_505) }
|
||||
let(:beachmont) { School.find_or_create_by(name: 'Beachmont', dese_id: 2_480_013) }
|
||||
let(:winchester) { School.find_or_create_by(name: 'Winchester', dese_id: 3_440_505) }
|
||||
let(:attleboro) { create(:school, name: "Attleboro", dese_id: 160_505) }
|
||||
let(:beachmont) { create(:school, name: "Beachmont", dese_id: 2_480_013) }
|
||||
let(:winchester) { create(:school, name: "Winchester", dese_id: 3_440_505) }
|
||||
before :each do
|
||||
ay_2022_23
|
||||
attleboro
|
||||
|
|
@ -19,8 +19,8 @@ describe EnrollmentLoader do
|
|||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
context 'self.load_data' do
|
||||
it 'loads the correct enrollment numbers' do
|
||||
context "self.load_data" do
|
||||
it "loads the correct enrollment numbers" do
|
||||
academic_year = ay_2022_23
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).nine).to eq 506
|
||||
# expect(Respondent.find_by(school: attleboro, academic_year:).total_students).to eq 1844
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe StaffingLoader do
|
||||
let(:path_to_staffing_data) { Rails.root.join('spec', 'fixtures', 'sample_staffing_data.csv') }
|
||||
let(:ay_2022_23) { create(:academic_year, range: '2022-23') }
|
||||
let(:ay_2021_22) { create(:academic_year, range: '2021-22') }
|
||||
let(:attleboro) { School.find_or_create_by(name: 'Attleboro', dese_id: 160_505) }
|
||||
let(:beachmont) { School.find_or_create_by(name: 'Beachmont', dese_id: 2_480_013) }
|
||||
let(:winchester) { School.find_or_create_by(name: 'Winchester', dese_id: 3_440_505) }
|
||||
let(:path_to_staffing_data) { Rails.root.join("spec", "fixtures", "sample_staffing_data.csv") }
|
||||
let(:ay_2022_23) { create(:academic_year, range: "2022-23") }
|
||||
let(:ay_2021_22) { create(:academic_year, range: "2021-22") }
|
||||
let(:attleboro) { create(:school, name: "Attleboro", dese_id: 160_505) }
|
||||
let(:beachmont) { create(:school, name: "Beachmont", dese_id: 2_480_013) }
|
||||
let(:winchester) { create(:school, name: "Winchester", dese_id: 3_440_505) }
|
||||
|
||||
before :each do
|
||||
ay_2022_23
|
||||
|
|
@ -22,8 +22,8 @@ describe StaffingLoader do
|
|||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
context 'self.load_data' do
|
||||
it 'loads the correct staffing numbers' do
|
||||
context "self.load_data" do
|
||||
it "loads the correct staffing numbers" do
|
||||
academic_year = ay_2021_22
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
|
||||
|
|
@ -32,11 +32,11 @@ describe StaffingLoader do
|
|||
expect(Respondent.find_by(school: winchester, academic_year:).total_teachers).to eq 149.8
|
||||
end
|
||||
|
||||
context 'when the staffing data is missing a school' do
|
||||
context "when the staffing data is missing a school" do
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
it 'fills in empty staffing numbers with the previous years data' do
|
||||
it "fills in empty staffing numbers with the previous years data" do
|
||||
academic_year = ay_2022_23
|
||||
expect(Respondent.find_by(school: attleboro, academic_year:).total_teachers).to eq 197.5
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue