From b111b2f10618f767c511dee252db167bc477db84 Mon Sep 17 00:00:00 2001 From: Nelson Jovel Date: Sat, 15 Jan 2022 12:43:01 +0100 Subject: [PATCH] Bump rails to 7 and get tests passing. Also modified rakefile so rake command would continue to run rspec as the default command. Added stylesheets to assets.rb so they'll be included when precompiling assets in production. --- Gemfile | 7 +- Gemfile.lock | 163 ++++++++++-------- Rakefile | 11 +- app/assets/config/manifest.js | 5 +- ...application.scss => application.sass.scss} | 0 .../stylesheets/partials/_sqm_bootstrap.scss | 1 - .../{sqm_application.scss => sqm.sass.scss} | 2 +- .../{welcome.scss => welcome.sass.scss} | 0 app/views/layouts/application.html.erb | 2 +- app/views/layouts/home.html.erb | 2 +- config/application.rb | 1 + config/initializers/assets.rb | 2 +- package.json | 4 +- spec/views/categories/show.html.erb_spec.rb | 2 +- spec/views/home/index.html.erb_spec.rb | 2 +- spec/views/overview/index.html.erb_spec.rb | 2 +- 16 files changed, 113 insertions(+), 93 deletions(-) rename app/assets/stylesheets/{application.scss => application.sass.scss} (100%) rename app/assets/stylesheets/{sqm_application.scss => sqm.sass.scss} (100%) rename app/assets/stylesheets/{welcome.scss => welcome.sass.scss} (100%) diff --git a/Gemfile b/Gemfile index b2ba7159..a0484a9f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,13 +7,15 @@ git_source(:github) do |repo_name| end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.1.4.4' +gem 'rails', '~> 7.0.1' +gem 'sprockets-rails' + gem 'pg' # Use Puma as the app server gem 'puma', '>= 5.5.2' # Use SCSS for stylesheets -gem 'sassc-rails', require: false +# gem 'sassc-rails', require: false # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes @@ -70,7 +72,6 @@ group :development do gem 'rubocop', require: false gem 'seed_dump' gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' end group 'test' do diff --git a/Gemfile.lock b/Gemfile.lock index 93cbad94..8a5da6b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,74 +10,80 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + actioncable (7.0.1) + actionpack (= 7.0.1) + activesupport (= 7.0.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailbox (7.0.1) + actionpack (= 7.0.1) + activejob (= 7.0.1) + activerecord (= 7.0.1) + activestorage (= 7.0.1) + activesupport (= 7.0.1) mail (>= 2.7.1) - actionmailer (6.1.4.4) - actionpack (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activesupport (= 6.1.4.4) + net-imap + net-pop + net-smtp + actionmailer (7.0.1) + actionpack (= 7.0.1) + actionview (= 7.0.1) + activejob (= 7.0.1) + activesupport (= 7.0.1) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.4.4) - actionview (= 6.1.4.4) - activesupport (= 6.1.4.4) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.1) + actionview (= 7.0.1) + activesupport (= 7.0.1) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.4) - actionpack (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actiontext (7.0.1) + actionpack (= 7.0.1) + activerecord (= 7.0.1) + activestorage (= 7.0.1) + activesupport (= 7.0.1) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.4.4) - activesupport (= 6.1.4.4) + actionview (7.0.1) + activesupport (= 7.0.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.4) - activesupport (= 6.1.4.4) + activejob (7.0.1) + activesupport (= 7.0.1) globalid (>= 0.3.6) - activemodel (6.1.4.4) - activesupport (= 6.1.4.4) - activerecord (6.1.4.4) - activemodel (= 6.1.4.4) - activesupport (= 6.1.4.4) + activemodel (7.0.1) + activesupport (= 7.0.1) + activerecord (7.0.1) + activemodel (= 7.0.1) + activesupport (= 7.0.1) activerecord-import (1.3.0) activerecord (>= 4.2) - activestorage (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activesupport (= 6.1.4.4) - marcel (~> 1.0.0) + activestorage (7.0.1) + actionpack (= 7.0.1) + activejob (= 7.0.1) + activerecord (= 7.0.1) + activesupport (= 7.0.1) + marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.4.4) + activesupport (7.0.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.10.1) - msgpack (~> 1.2) + bootsnap (1.9.4) + msgpack (~> 1.0) builder (3.2.4) bullet (7.0.1) activesupport (>= 3.0.0) @@ -109,6 +115,7 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.5.0) + digest (3.1.0) erubi (1.10.0) execjs (2.8.1) factory_bot (6.2.0) @@ -127,6 +134,7 @@ GEM hashie (5.0.0) i18n (1.8.11) concurrent-ruby (~> 1.0) + io-wait (0.2.1) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -155,6 +163,21 @@ GEM msgpack (1.4.2) multi_json (1.15.0) nested_scaffold (1.1.0) + net-imap (0.2.3) + digest + net-protocol + strscan + net-pop (0.1.1) + digest + net-protocol + timeout + net-protocol (0.1.2) + io-wait + timeout + net-smtp (0.3.1) + digest + net-protocol + timeout newrelic_rpm (8.3.0) nio4r (2.5.8) nokogiri (1.13.1-x86_64-darwin) @@ -179,21 +202,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.4.4) - actioncable (= 6.1.4.4) - actionmailbox (= 6.1.4.4) - actionmailer (= 6.1.4.4) - actionpack (= 6.1.4.4) - actiontext (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activemodel (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + rails (7.0.1) + actioncable (= 7.0.1) + actionmailbox (= 7.0.1) + actionmailer (= 7.0.1) + actionpack (= 7.0.1) + actiontext (= 7.0.1) + actionview (= 7.0.1) + activejob (= 7.0.1) + activemodel (= 7.0.1) + activerecord (= 7.0.1) + activestorage (= 7.0.1) + activesupport (= 7.0.1) bundler (>= 1.15.0) - railties (= 6.1.4.4) - sprockets-rails (>= 2.0.0) + railties (= 7.0.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -203,12 +225,13 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + railties (7.0.1) + actionpack (= 7.0.1) + activesupport (= 7.0.1) method_source - rake (>= 0.13) + rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.0) @@ -248,21 +271,10 @@ GEM rubocop-ast (1.15.1) parser (>= 3.0.1.1) ruby-progressbar (1.11.0) - sassc (2.4.0) - ffi (~> 1.9) - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt seed_dump (3.3.1) activerecord (>= 4) activesupport (>= 4) - spring (2.1.1) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) + spring (4.0.0) sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -270,10 +282,12 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + strscan (3.0.1) temple (0.8.2) thor (1.2.1) tilt (2.0.10) timecop (0.9.4) + timeout (0.2.0) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -329,14 +343,13 @@ DEPENDENCIES omniauth pg puma (>= 5.5.2) - rails (~> 6.1.4.4) + rails (~> 7.0.1) rails-controller-testing rspec-rails (~> 4.1.2) rubocop - sassc-rails seed_dump spring - spring-watcher-listen (~> 2.0.0) + sprockets-rails timecop turbolinks (~> 5) twilio-ruby (~> 4.11.1) diff --git a/Rakefile b/Rakefile index e85f9139..3f1ba47b 100644 --- a/Rakefile +++ b/Rakefile @@ -2,5 +2,14 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require_relative 'config/application' - Rails.application.load_tasks + +begin + require 'rspec/core/rake_task' + RSpec::Core::RakeTask.new(:spec) + + # task(:default).clear + task default: :spec +rescue LoadError => e + raise e unless ENV['RAILS_ENV'] == 'production' +end diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index cc2f0c69..f7ab0aa7 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,6 +1,3 @@ //= link_tree ../images -//= link_directory ../javascripts .js -//= link sqm_application.css -//= link application.css -//= link welcome.css //= link_tree ../builds +//= link_directory ../javascripts .js diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.sass.scss similarity index 100% rename from app/assets/stylesheets/application.scss rename to app/assets/stylesheets/application.sass.scss diff --git a/app/assets/stylesheets/partials/_sqm_bootstrap.scss b/app/assets/stylesheets/partials/_sqm_bootstrap.scss index 646617c0..f37e3c2b 100644 --- a/app/assets/stylesheets/partials/_sqm_bootstrap.scss +++ b/app/assets/stylesheets/partials/_sqm_bootstrap.scss @@ -46,7 +46,6 @@ // Utilities @import "bootstrap/scss/utilities/api"; - .popover { box-shadow: 0 0 8px rgba($black, 0.25); } diff --git a/app/assets/stylesheets/sqm_application.scss b/app/assets/stylesheets/sqm.sass.scss similarity index 100% rename from app/assets/stylesheets/sqm_application.scss rename to app/assets/stylesheets/sqm.sass.scss index 97aeb32b..1a9576ed 100644 --- a/app/assets/stylesheets/sqm_application.scss +++ b/app/assets/stylesheets/sqm.sass.scss @@ -1,6 +1,6 @@ @import "partials/colors"; -@import "partials/sqm_bootstrap"; @import "partials/bootstrap-overrides"; +@import "partials/sqm_bootstrap"; @import "partials/clear-margin-padding"; @import "partials/fonts"; @import "partials/borders"; diff --git a/app/assets/stylesheets/welcome.scss b/app/assets/stylesheets/welcome.sass.scss similarity index 100% rename from app/assets/stylesheets/welcome.scss rename to app/assets/stylesheets/welcome.sass.scss diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c0630e2f..1d497ffd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,7 +7,7 @@ MCIEA <%= csp_meta_tag %> - <%= stylesheet_link_tag 'sqm_application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'sqm', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= render partial: 'layouts/google_analytics', locals: { google_analytics_id: @google_analytics_id } %> <%= render partial: 'layouts/hotjar', locals: { hotjar_id: @hotjar_id } %> diff --git a/app/views/layouts/home.html.erb b/app/views/layouts/home.html.erb index 26dc8a0e..61625735 100644 --- a/app/views/layouts/home.html.erb +++ b/app/views/layouts/home.html.erb @@ -3,7 +3,7 @@ MCIEA - <%= stylesheet_link_tag 'sqm_application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'sqm', media: 'all', 'data-turbolinks-track': 'reload' %> <%= stylesheet_link_tag 'welcome', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= render partial: 'layouts/google_analytics', locals: { google_analytics_id: @google_analytics_id } %> diff --git a/config/application.rb b/config/application.rb index 4864bab0..3199f0d9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,5 +11,6 @@ module Edcontext # 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 end end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index fe48fc34..3458d355 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -9,4 +9,4 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. -# Rails.application.config.assets.precompile += %w( admin.js admin.css ) +Rails.application.config.assets.precompile += %w( application.css sqm.css welcome.css) diff --git a/package.json b/package.json index fb86ff33..796dfebd 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "scripts": { "build": "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds", "test": "jest", - "build:css": "sass ./app/assets/stylesheets/application.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules & sass ./app/assets/stylesheets/sqm_application.scss ./app/assets/builds/sqm_application.css --no-source-map --load-path=node_modules & sass ./app/assets/stylesheets/welcome.scss ./app/assets/builds/welcome.css --no-source-map --load-path=node_modules", - "watch:css": "sass ./app/assets/stylesheets/application.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules --watch & sass ./app/assets/stylesheets/sqm_application.scss ./app/assets/builds/sqm_application.css --no-source-map --load-path=node_modules --watch & sass ./app/assets/stylesheets/welcome.scss ./app/assets/builds/welcome.css --no-source-map --load-path=node_modules --watch", + "build:css": "sass ./app/assets/stylesheets/application.sass.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules ; sass ./app/assets/stylesheets/sqm.sass.scss ./app/assets/builds/sqm.css --no-source-map --load-path=node_modules ; sass ./app/assets/stylesheets/welcome.sass.scss ./app/assets/builds/welcome.css --no-source-map --load-path=node_modules", + "watch:css": "sass ./app/assets/stylesheets/application.sass.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules --watch & sass ./app/assets/stylesheets/sqm.sass.scss ./app/assets/builds/sqm.css --no-source-map --load-path=node_modules --watch & sass ./app/assets/stylesheets/welcome.sass.scss ./app/assets/builds/welcome.css --no-source-map --load-path=node_modules --watch", "watch:all": "yarn watch:css & yarn build --watch" }, "devDependencies": { diff --git a/spec/views/categories/show.html.erb_spec.rb b/spec/views/categories/show.html.erb_spec.rb index 62546e10..17631b22 100644 --- a/spec/views/categories/show.html.erb_spec.rb +++ b/spec/views/categories/show.html.erb_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'categories/show.html.erb' do +describe 'categories/show' do before :each do academic_year = create(:academic_year, range: '1989-90') school = create(:school, name: 'Best School') diff --git a/spec/views/home/index.html.erb_spec.rb b/spec/views/home/index.html.erb_spec.rb index dffd9a2e..773a7574 100644 --- a/spec/views/home/index.html.erb_spec.rb +++ b/spec/views/home/index.html.erb_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/index.html.erb' do +describe 'home/index' do subject { Nokogiri::HTML(rendered) } before :each do diff --git a/spec/views/overview/index.html.erb_spec.rb b/spec/views/overview/index.html.erb_spec.rb index 95d68a4c..3a0232ea 100644 --- a/spec/views/overview/index.html.erb_spec.rb +++ b/spec/views/overview/index.html.erb_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'overview/index.html.erb' do +describe 'overview/index' do subject { Nokogiri::HTML(rendered) } let(:support_for_teaching) do