From c22224d0e76da14302830df5d95559c754857691 Mon Sep 17 00:00:00 2001 From: adi-herwana-nus Date: Tue, 10 Sep 2024 03:01:35 +0800 Subject: [PATCH] chore(rails): upgrade to rails 7.1.4 - removed deprecated fixture_path config keys - updated certain enum fields to be attributes - changed @connection to @raw_connection in database extension --- Gemfile | 7 +- Gemfile.lock | 159 ++++++++++-------- app/models/course/survey.rb | 1 + app/models/course/survey/question.rb | 1 + .../database_event/active_record/base.rb | 2 +- .../question/programming_management_spec.rb | 4 +- spec/libraries/duplicator_spec.rb | 7 +- spec/rails_helper.rb | 2 +- 8 files changed, 105 insertions(+), 78 deletions(-) diff --git a/Gemfile b/Gemfile index d17f2577c6f..fe90f4c7efa 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ ruby '3.1.4' gem 'tzinfo-data', platforms: [:mswin, :mswin64] # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 7.0.8.4' +gem 'rails', '~> 7.1.4' # Use PostgreSQL for the backend gem 'pg' @@ -180,11 +180,6 @@ gem 'jwt' # Use cancancan for authorization gem 'cancancan' -# Some helpers for structuring CSS/JavaScript -# Official version https://github.com/winston/rails_utils/pull/30 is no longer maintained. -# We also want stricter sanitization. -# gem 'rails_utils', git: 'https://github.com/Coursemology/rails_utils.git' - # Using CarrierWave for file uploads gem 'carrierwave', '2.2.6' # Generate sequential filenames diff --git a/Gemfile.lock b/Gemfile.lock index 642ff246554..0a2f05c5583 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,75 +36,84 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.4) - actionpack (= 7.0.8.4) - activesupport (= 7.0.8.4) + actioncable (7.1.4) + actionpack (= 7.1.4) + activesupport (= 7.1.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.4) - actionpack (= 7.0.8.4) - activejob (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + zeitwerk (~> 2.6) + actionmailbox (7.1.4) + actionpack (= 7.1.4) + activejob (= 7.1.4) + activerecord (= 7.1.4) + activestorage (= 7.1.4) + activesupport (= 7.1.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.4) - actionpack (= 7.0.8.4) - actionview (= 7.0.8.4) - activejob (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionmailer (7.1.4) + actionpack (= 7.1.4) + actionview (= 7.1.4) + activejob (= 7.1.4) + activesupport (= 7.1.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.4) - actionview (= 7.0.8.4) - activesupport (= 7.0.8.4) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.4) + actionview (= 7.1.4) + activesupport (= 7.1.4) + nokogiri (>= 1.8.5) + racc + 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.4) - actionpack (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.4) + actionpack (= 7.1.4) + activerecord (= 7.1.4) + activestorage (= 7.1.4) + activesupport (= 7.1.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.4) - activesupport (= 7.0.8.4) + actionview (7.1.4) + activesupport (= 7.1.4) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_record_upsert (0.11.2) activerecord (>= 5.2, < 7.2) pg (>= 0.18, < 2.0) - activejob (7.0.8.4) - activesupport (= 7.0.8.4) + activejob (7.1.4) + activesupport (= 7.1.4) globalid (>= 0.3.6) - activemodel (7.0.8.4) - activesupport (= 7.0.8.4) - activerecord (7.0.8.4) - activemodel (= 7.0.8.4) - activesupport (= 7.0.8.4) + activemodel (7.1.4) + activesupport (= 7.1.4) + activerecord (7.1.4) + activemodel (= 7.1.4) + activesupport (= 7.1.4) + timeout (>= 0.4.0) activerecord-import (1.8.1) activerecord (>= 4.2) - activestorage (7.0.8.4) - actionpack (= 7.0.8.4) - activejob (= 7.0.8.4) - activerecord (= 7.0.8.4) - activesupport (= 7.0.8.4) + activestorage (7.1.4) + actionpack (= 7.1.4) + activejob (= 7.1.4) + activerecord (= 7.1.4) + activesupport (= 7.1.4) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.4) + activesupport (7.1.4) + 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) acts_as_tenant (1.0.1) rails (>= 6.0) @@ -132,6 +141,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) base64 (0.2.0) bcrypt (3.1.20) + bigdecimal (3.1.8) builder (3.3.0) bullet (7.2.0) activesupport (>= 3.0.0) @@ -189,6 +199,7 @@ GEM dotenv-rails (3.1.2) dotenv (= 3.1.2) railties (>= 6.1) + drb (2.2.1) edge (0.6.1) activerecord (>= 5.0.0) email_spec (2.3.0) @@ -269,6 +280,10 @@ GEM ruby-vips (>= 2.0.17, < 3) image_size (3.4.0) in_threads (1.6.0) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -322,7 +337,6 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) - method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) mime-types-data (3.2024.0820) @@ -334,6 +348,7 @@ GEM mini_portile2 (2.8.7) minitest (5.25.1) multi_json (1.15.0) + mutex_m (0.2.0) net-imap (0.4.14) date net-protocol @@ -357,6 +372,8 @@ GEM racc pg (1.5.8) progress (3.6.0) + psych (5.1.2) + stringio public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) @@ -371,20 +388,23 @@ GEM rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.4) - actioncable (= 7.0.8.4) - actionmailbox (= 7.0.8.4) - actionmailer (= 7.0.8.4) - actionpack (= 7.0.8.4) - actiontext (= 7.0.8.4) - actionview (= 7.0.8.4) - activejob (= 7.0.8.4) - activemodel (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.4) + actioncable (= 7.1.4) + actionmailbox (= 7.1.4) + actionmailer (= 7.1.4) + actionpack (= 7.1.4) + actiontext (= 7.1.4) + actionview (= 7.1.4) + activejob (= 7.1.4) + activemodel (= 7.1.4) + activerecord (= 7.1.4) + activestorage (= 7.1.4) + activesupport (= 7.1.4) bundler (>= 1.15.0) - railties (= 7.0.8.4) + railties (= 7.1.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -399,18 +419,21 @@ GEM rails-i18n (7.0.9) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.0.8.4) - actionpack (= 7.0.8.4) - activesupport (= 7.0.8.4) - method_source + railties (7.1.4) + actionpack (= 7.1.4) + activesupport (= 7.1.4) + 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.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) recaptcha (5.17.0) record_tag_helper (1.0.1) actionview (>= 5) @@ -435,6 +458,8 @@ GEM redis-store (1.10.0) redis (>= 4, < 6) regexp_parser (2.9.2) + reline (0.5.10) + io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) responders (3.1.1) @@ -540,6 +565,7 @@ GEM rack (>= 2.2.4, < 4) ssrf_filter (1.1.2) stackprof (0.2.26) + stringio (3.1.1) temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) @@ -559,6 +585,7 @@ GEM activesupport (>= 3.0) warden (1.2.9) rack (>= 2.0.9) + webrick (1.8.1) websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -628,7 +655,7 @@ DEPENDENCIES puma rack-cors rack-mini-profiler - rails (~> 7.0.8.4) + rails (~> 7.1.4) rails-controller-testing rails-html-sanitizer (>= 1.0.4) recaptcha diff --git a/app/models/course/survey.rb b/app/models/course/survey.rb index b6005197d01..86365f2e979 100644 --- a/app/models/course/survey.rb +++ b/app/models/course/survey.rb @@ -5,6 +5,7 @@ class Course::Survey < ApplicationRecord include Course::ClosingReminderConcern + attribute :question_type, :integer enum question_type: { text_response: 0, multiple_choice: 1, multiple_response: 2 } validates :end_at, presence: true, if: :allow_response_after_end diff --git a/app/models/course/survey/question.rb b/app/models/course/survey/question.rb index cfbd97192fe..50c391bf06c 100644 --- a/app/models/course/survey/question.rb +++ b/app/models/course/survey/question.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true class Course::Survey::Question < ApplicationRecord + attribute :question_type, :integer enum question_type: { text: 0, multiple_choice: 1, multiple_response: 2 } validates :description, presence: true diff --git a/lib/extensions/database_event/active_record/base.rb b/lib/extensions/database_event/active_record/base.rb index a7cef300bf3..0d4d0b0cdd0 100644 --- a/lib/extensions/database_event/active_record/base.rb +++ b/lib/extensions/database_event/active_record/base.rb @@ -58,7 +58,7 @@ def wait_for_identifier(identifier, deadline, while_callback, &block) def wait_until(deadline, while_callback, &block) while deadline.nil? || Time.zone.now < deadline wait_timeout = deadline ? deadline - Time.zone.now : nil - result = connection.instance_variable_get(:@connection). + result = connection.instance_variable_get(:@raw_connection). wait_for_notify(wait_timeout, &block) return result if while_callback.nil? || !while_callback.call end diff --git a/spec/features/course/assessment/question/programming_management_spec.rb b/spec/features/course/assessment/question/programming_management_spec.rb index 036ae690e3c..fb02c5d38c5 100644 --- a/spec/features/course/assessment/question/programming_management_spec.rb +++ b/spec/features/course/assessment/question/programming_management_spec.rb @@ -119,8 +119,8 @@ question = create(:course_assessment_question_programming, assessment: assessment, template_file_count: 0, package_type: :zip_upload) - empty_package = File.join(fixture_path, 'course/empty_programming_question_template.zip') - valid_package = File.join(fixture_path, 'course/programming_question_template.zip') + empty_package = File.join(file_fixture_path, 'course/empty_programming_question_template.zip') + valid_package = File.join(file_fixture_path, 'course/programming_question_template.zip') visit edit_course_assessment_question_programming_path(course, assessment, question) find('span', text: 'Evaluate and test code').click diff --git a/spec/libraries/duplicator_spec.rb b/spec/libraries/duplicator_spec.rb index da3fc55f255..e31cf1ebc5a 100644 --- a/spec/libraries/duplicator_spec.rb +++ b/spec/libraries/duplicator_spec.rb @@ -410,8 +410,11 @@ def initialize_duplicate(duplicator, other) end temporary_table(:children_parents) do |t| - t.integer :children_id, foreign_key: { references: :complex_active_records, primary_key: :id } - t.integer :parent_id, foreign_key: { references: :complex_active_records, primary_key: :id } + # Something in Rails 7.1 upgrade broke the one-line declarations here. + t.integer :children_id + t.foreign_key :complex_active_records, column: :children_id, primary_key: :id + t.integer :parent_id + t.foreign_key :complex_active_records, column: :parent_id, primary_key: :id end class DuplicationTraceableActiveRecordWithSource < ApplicationRecord diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5c08a13a168..3fb1d38b5d8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -46,7 +46,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + # config.fixture_paths = ["#{::Rails.root}/spec/fixtures"] config.file_fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your