From 9d680c515943f31b9f9fbb83195dd662ca4a5546 Mon Sep 17 00:00:00 2001 From: rebuilt Date: Fri, 6 Oct 2023 14:41:16 -0700 Subject: [PATCH] chore: upgrade to rails 7.1. upgrade rspec fix failing tests upgrade devise --- Gemfile | 7 +- Gemfile.lock | 281 ++++++++++-------- app/models/survey_item_response.rb | 8 +- app/presenters/analyze/group/sped.rb | 2 +- app/services/enrollment_loader.rb | 36 +-- config/application.rb | 9 +- config/secrets.yml | 22 -- db/schema.rb | 2 +- spec/presenters/subcategory_presenter_spec.rb | 73 ++--- spec/rails_helper.rb | 14 +- spec/services/enrollment_loader_spec.rb | 16 +- spec/services/staffing_loader_spec.rb | 22 +- 12 files changed, 250 insertions(+), 242 deletions(-) delete mode 100644 config/secrets.yml diff --git a/Gemfile b/Gemfile index 741c4ff9..ed3b0fb6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ git_source(:github) do |repo_name| end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem "rails", "~> 7.0.8" +gem "rails", "~> 7.1.0" gem "sprockets-rails" gem "pg" @@ -36,7 +36,7 @@ gem "friendly_id", "~> 5.1.0" gem "newrelic_rpm" -gem "devise" +gem "devise", git: "https://github.com/heartcombo/devise" gem "omniauth" @@ -66,8 +66,7 @@ group :development, :test do gem "factory_bot_rails" gem "parallel_tests" gem "rack-mini-profiler" - gem "rspec-rails", "~> 5.1.0" - gem "debug", platforms: %i[mri mingw x64_mingw] + gem "rspec-rails", "~> 6.0.3" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 45345046..3070f5ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,77 +1,97 @@ +GIT + remote: https://github.com/heartcombo/devise + revision: 9064ecbf15bffc9ec70ec8ff4061a974e7621156 + specs: + devise (4.9.2) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) + GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.0) + actionpack (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activesupport (= 7.1.0) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.0) + actionview (= 7.1.0) + activesupport (= 7.1.0) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.0) + actionpack (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.0) + activesupport (= 7.1.0) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.0) + activesupport (= 7.1.0) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activerecord-import (1.4.1) + activemodel (7.1.0) + activesupport (= 7.1.0) + activerecord (7.1.0) + activemodel (= 7.1.0) + activesupport (= 7.1.0) + timeout (>= 0.4.0) + activerecord-import (1.5.0) activerecord (>= 4.2) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activestorage (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activesupport (= 7.1.0) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.0) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - addressable (2.8.4) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) backport (1.2.0) + base64 (0.1.1) bcrypt (3.1.19) bcrypt_pbkdf (1.1.0) benchmark (0.2.1) @@ -82,11 +102,12 @@ GEM erubi (~> 1.4) parser (>= 2.4) smart_properties + bigdecimal (3.1.4) bootsnap (1.16.0) msgpack (~> 1.2) - brakeman (6.0.0) + brakeman (6.0.1) builder (3.2.4) - bullet (7.0.7) + bullet (7.1.0) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) @@ -101,13 +122,14 @@ GEM xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.2.2) + connection_pool (2.4.1) crass (1.0.6) - cssbundling-rails (1.2.0) + cssbundling-rails (1.3.3) railties (>= 6.0.0) cuprite (0.14.3) capybara (~> 3.0) ferrum (~> 0.13.0) - cypress-rails (0.6.0) + cypress-rails (0.6.1) puma (>= 3.8.0) railties (>= 5.2.0) database_cleaner (2.0.2) @@ -117,37 +139,30 @@ GEM database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) date (3.3.3) - debug (1.8.0) - irb (>= 1.5.0) - reline (>= 0.3.1) - devise (4.9.2) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 4.1.0) - responders - warden (~> 1.2.3) diff-lcs (1.5.0) docile (1.4.0) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) railties (>= 3.2) + drb (2.1.1) + ruby2_keywords e2mmap (0.1.0) ed25519 (1.3.0) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - erb_lint (0.4.0) + erb_lint (0.5.0) activesupport better_html (>= 2.0.1) parser (>= 2.7.1.4) rainbow rubocop smart_properties - erblint-github (0.4.1) + erblint-github (0.5.0) erubi (1.12.0) eventmachine (1.2.7) - execjs (2.8.1) + execjs (2.9.1) factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) @@ -158,13 +173,13 @@ GEM concurrent-ruby (~> 1.1) webrick (~> 1.7) websocket-driver (>= 0.6, < 0.8) - ffi (1.15.5) + ffi (1.16.3) formatador (1.1.0) friendly_id (5.1.0) activerecord (>= 4.0.0) globalid (1.2.1) activesupport (>= 6.1) - guard (2.18.0) + guard (2.18.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) @@ -183,7 +198,7 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - haml (6.1.1) + haml (6.2.3) temple (>= 0.8.2) thor tilt @@ -192,8 +207,9 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) io-console (0.6.0) - irb (1.7.4) - reline (>= 0.3.6) + irb (1.8.1) + rdoc + reline (>= 0.3.8) jaro_winkler (1.5.6) jbuilder (2.11.5) actionview (>= 5.0.0) @@ -202,7 +218,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jsbundling-rails (1.1.2) + jsbundling-rails (1.2.1) railties (>= 6.0.0) json (2.6.3) kramdown (2.4.0) @@ -216,10 +232,10 @@ GEM listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.21.3) + loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) - lumberjack (1.2.8) + lumberjack (1.2.9) mail (2.8.1) mini_mime (>= 0.1.1) net-imap @@ -230,11 +246,12 @@ GEM method_source (1.0.0) mini_mime (1.1.5) minitest (5.20.0) - msgpack (1.7.0) + msgpack (1.7.2) multi_json (1.15.0) + mutex_m (0.1.2) nenv (0.3.0) nested_scaffold (1.1.0) - net-imap (0.3.7) + net-imap (0.4.0) date net-protocol net-pop (0.1.2) @@ -245,8 +262,8 @@ GEM net-ssh (>= 5.0.0, < 8.0.0) net-smtp (0.4.0) net-protocol - net-ssh (7.1.0) - newrelic_rpm (9.3.1) + net-ssh (7.2.0) + newrelic_rpm (9.5.0) nio4r (2.5.9) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) @@ -263,42 +280,49 @@ GEM rack-protection orm_adapter (0.5.0) parallel (1.23.0) - parallel_tests (4.2.1) + parallel_tests (4.2.2) parallel - parser (3.2.2.3) + parser (3.2.2.4) ast (~> 2.4.1) racc - pg (1.5.3) + pg (1.5.4) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.0.1) + psych (5.1.1) + stringio + public_suffix (5.0.3) puma (6.4.0) nio4r (~> 2.0) racc (1.7.1) - rack (2.2.8) + rack (3.0.8) rack-livereload (0.5.1) rack - rack-mini-profiler (3.1.0) + rack-mini-profiler (3.1.1) rack (>= 1.2.0) rack-protection (3.0.6) rack + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.0) + actioncable (= 7.1.0) + actionmailbox (= 7.1.0) + actionmailer (= 7.1.0) + actionpack (= 7.1.0) + actiontext (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activemodel (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -310,33 +334,36 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rbs (2.8.4) + rdoc (6.5.0) + psych (>= 4.0.0) redis (3.3.5) reek (6.1.4) kwalify (~> 0.7.0) parser (~> 3.2.0) rainbow (>= 2.0, < 4.0) regexp_parser (2.8.1) - reline (0.3.6) + reline (0.3.9) io-console (~> 0.5) responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) reverse_markdown (2.1.1) nokogiri - rexml (3.2.5) + rexml (3.2.6) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) @@ -349,16 +376,17 @@ GEM rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) + rspec-rails (6.0.3) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) rspec-support (3.12.1) - rubocop (1.54.2) + rubocop (1.56.4) + base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -366,17 +394,18 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) rubyzip (2.3.2) seed_dump (3.3.1) activerecord (>= 4) activesupport (>= 4) - selenium-webdriver (4.10.0) + selenium-webdriver (4.13.1) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -408,7 +437,7 @@ GEM reek (>= 5.0) solargraph (~> 0.38) spring (4.1.1) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) @@ -416,12 +445,13 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) standard_deviation (1.0.3) - stimulus-rails (1.2.1) + stimulus-rails (1.2.2) railties (>= 6.0.0) - temple (0.10.2) + stringio (3.0.8) + temple (0.10.3) thor (1.2.2) - tilt (2.2.0) - timecop (0.9.6) + tilt (2.3.0) + timecop (0.9.8) timeout (0.4.0) turbo-rails (1.4.0) actionpack (>= 6.0.0) @@ -431,21 +461,21 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) uniform_notifier (1.16.0) warden (1.2.9) rack (>= 2.0.9) - watir (7.2.2) + watir (7.3.0) regexp_parser (>= 1.2, < 3) selenium-webdriver (~> 4.2) webrick (1.8.1) - websocket (1.2.9) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.32) + yard (0.9.34) zeitwerk (2.6.12) PLATFORMS @@ -464,8 +494,7 @@ DEPENDENCIES cuprite cypress-rails database_cleaner - debug - devise + devise! dotenv-rails ed25519 erb_lint @@ -491,11 +520,11 @@ DEPENDENCIES puma (>= 5.6.4) rack-livereload rack-mini-profiler - rails (~> 7.0.8) + rails (~> 7.1.0) rails-controller-testing redis (~> 3.0) reline (~> 0.3.2) - rspec-rails (~> 5.1.0) + rspec-rails (~> 6.0.3) rubocop seed_dump simplecov diff --git a/app/models/survey_item_response.rb b/app/models/survey_item_response.rb index 5bf4d390..03dd4585 100644 --- a/app/models/survey_item_response.rb +++ b/app/models/survey_item_response.rb @@ -8,10 +8,10 @@ class SurveyItemResponse < ActiveRecord::Base belongs_to :school belongs_to :survey_item, counter_cache: true belongs_to :student, foreign_key: :student_id, optional: true - belongs_to :gender - belongs_to :income - belongs_to :ell - belongs_to :sped + belongs_to :gender, optional: true + belongs_to :income, optional: true + belongs_to :ell, optional: true + belongs_to :sped, optional: true has_one :measure, through: :survey_item diff --git a/app/presenters/analyze/group/sped.rb b/app/presenters/analyze/group/sped.rb index 0ea4c98e..6f4b2216 100644 --- a/app/presenters/analyze/group/sped.rb +++ b/app/presenters/analyze/group/sped.rb @@ -2,7 +2,7 @@ module Analyze module Group class Sped def name - "SpEd" + "Special Education" end def slug diff --git a/app/services/enrollment_loader.rb b/app/services/enrollment_loader.rb index 29f11ecd..572321b6 100644 --- a/app/services/enrollment_loader.rb +++ b/app/services/enrollment_loader.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'csv' +require "csv" class EnrollmentLoader def self.load_data(filepath:) @@ -57,75 +57,75 @@ class EnrollmentRowValues def school @school ||= begin - dese_id = row['DESE ID'].try(:strip).to_i + dese_id = row["DESE ID"].try(:strip).to_i School.find_by_dese_id(dese_id) end end def academic_year @academic_year ||= begin - year = row['Academic Year'] + year = row["Academic Year"] AcademicYear.find_by_range(year) end end def pk - row['PK'] || row['pk'] + row["PK"] || row["pk"] end def k - row['K'] || row['k'] + row["K"] || row["k"] end def one - row['1'] + row["1"] end def two - row['2'] + row["2"] end def three - row['3'] + row["3"] end def four - row['4'] + row["4"] end def five - row['5'] + row["5"] end def six - row['6'] + row["6"] end def seven - row['7'] + row["7"] end def eight - row['8'] + row["8"] end def nine - row['9'] + row["9"] end def ten - row['10'] + row["10"] end def eleven - row['11'] + row["11"] end def twelve - row['12'] + row["12"] end def total_students - row['Total'].gsub(',', '').to_i + row["Total"].delete(",").to_i end end diff --git a/config/application.rb b/config/application.rb index 3b8e40c7..8fe72ab3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,7 @@ -require_relative 'boot' +require_relative "boot" -require 'csv' -require 'rails/all' +require "csv" +require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -9,9 +9,10 @@ Bundler.require(*Rails.groups) module Edcontext class Application < Rails::Application + config.load_defaults 7.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - config.active_record.legacy_connection_handling = false + config.active_support.cache_format_version 6.1 end end diff --git a/config/secrets.yml b/config/secrets.yml deleted file mode 100644 index e7ba25d1..00000000 --- a/config/secrets.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rails secret` to generate a secure secret key. - -# Make sure the secrets in this file are kept private -# if you're sharing your code publicly. - -development: - secret_key_base: ca26427fb2b33e6bece85b12fed0097d3ee4cce91c5ca8514d0f849a8c69aee0e611c62d0feab522a3d7977bdf48b6b18abc4b05ee916afdb8fac941ede5fc12 - -test: - secret_key_base: 5d55aa31e1a50c4299d0791f05535204a061d520214cc62d74b7e093bf6af8ac73f28df259932047a1e51a386e06686051453e36c2ec62835cbf041c4d543157 - -# Do not keep production secrets in the repository, -# instead read values from the environment. -production: - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/db/schema.rb b/db/schema.rb index a31ae2bd..e210f507 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_10_04_211430) do +ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" diff --git a/spec/presenters/subcategory_presenter_spec.rb b/spec/presenters/subcategory_presenter_spec.rb index c42e05b5..dfd0c22d 100644 --- a/spec/presenters/subcategory_presenter_spec.rb +++ b/spec/presenters/subcategory_presenter_spec.rb @@ -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 diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index bdf10184..76e407ec 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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 diff --git a/spec/services/enrollment_loader_spec.rb b/spec/services/enrollment_loader_spec.rb index b947d3ae..b14aa23a 100644 --- a/spec/services/enrollment_loader_spec.rb +++ b/spec/services/enrollment_loader_spec.rb @@ -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 diff --git a/spec/services/staffing_loader_spec.rb b/spec/services/staffing_loader_spec.rb index cea86417..0e2f9b10 100644 --- a/spec/services/staffing_loader_spec.rb +++ b/spec/services/staffing_loader_spec.rb @@ -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