diff --git a/Gemfile b/Gemfile index a59a44361c..80ecf53e8e 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '~> 3.1.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 7.0.8' +gem 'rails', '~> 7.1.0' # Use mysql as the database for Active Record gem 'mysql2', '~> 0.5.5' # Use Puma as the app server @@ -135,7 +135,7 @@ gem 'memory_profiler', '~> 1.0.1' gem 'rack-mini-profiler', '~> 3.1.1' gem 'stackprof', '~> 0.2.25' -gem 'ddtrace', '~> 1.14.0' +gem 'ddtrace', '~> 1.15.0' # Make sure filesystem changes only happen at the end of a transaction gem 'after_commit_everywhere', '~> 1.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 66b1a3cb9c..6a9e9f0661 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,70 +2,78 @@ GEM remote: https://rubygems.org/ specs: ace-rails-ap (4.5) - 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) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.0) + activesupport (= 7.1.0) + activerecord (7.1.0) + activemodel (= 7.1.0) + activesupport (= 7.1.0) + timeout (>= 0.4.0) + 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.5) public_suffix (>= 2.0.2, < 6.0) @@ -85,6 +93,7 @@ GEM base64 (0.1.1) bcrypt (3.1.18) bcrypt_pbkdf (1.1.0) + bigdecimal (3.1.4) bindata (2.4.15) bindex (0.8.1) bootsnap (1.16.0) @@ -121,6 +130,7 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) concurrent-ruby (1.2.2) + connection_pool (2.4.1) counter_culture (3.5.0) activerecord (>= 4.2) activesupport (>= 4.2) @@ -133,13 +143,16 @@ GEM railties (>= 6.0.0) daemons (1.4.1) dalli (3.2.6) + datadog-ci (0.2.0) + msgpack date (3.3.3) - ddtrace (1.14.0) - debase-ruby_core_source (= 3.2.1) - libdatadog (~> 3.0.0.1.0) - libddwaf (~> 1.9.0.0.0) + ddtrace (1.15.0) + datadog-ci (~> 0.2.0) + debase-ruby_core_source (= 3.2.2) + libdatadog (~> 5.0.0.1.0) + libddwaf (~> 1.14.0.0.0) msgpack - debase-ruby_core_source (3.2.1) + debase-ruby_core_source (3.2.2) delayed_job (4.1.10) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.7) @@ -161,6 +174,8 @@ GEM docker-api (2.2.0) excon (>= 0.47.0) multi_json + drb (2.1.1) + ruby2_keywords ed25519 (1.3.0) erubi (1.12.0) exception_notification (4.5.0) @@ -181,7 +196,7 @@ GEM faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) faraday-net_http (3.0.2) - ffi (1.15.5) + ffi (1.16.3) flamegraph (0.9.5) glob (0.4.0) globalid (1.2.1) @@ -209,6 +224,10 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) + io-console (0.6.0) + irb (1.8.1) + rdoc + reline (>= 0.3.8) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -235,8 +254,8 @@ GEM addressable (~> 2.7) letter_opener (1.8.1) launchy (>= 2.2, < 3) - libdatadog (3.0.0.1.0-x86_64-linux) - libddwaf (1.9.0.0.1-x86_64-linux) + libdatadog (5.0.0.1.0-x86_64-linux) + libddwaf (1.14.0.0.0-x86_64-linux) ffi (~> 1.0) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) @@ -255,7 +274,6 @@ GEM marcel (1.0.2) matrix (0.4.2) memory_profiler (1.0.1) - method_source (1.0.0) mini_magick (4.11.0) mini_mime (1.1.5) minitest (5.20.0) @@ -270,8 +288,9 @@ GEM multi_xml (0.6.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) + mutex_m (0.1.2) mysql2 (0.5.5) - net-imap (0.3.7) + net-imap (0.4.0) date net-protocol net-pop (0.1.2) @@ -280,7 +299,7 @@ GEM timeout net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol net-ssh (7.1.0) nio4r (2.5.9) @@ -339,6 +358,8 @@ GEM premailer (~> 1.7, >= 1.7.9) pretender (0.5.0) actionpack (>= 6.1) + psych (5.1.0) + stringio public_suffix (5.0.3) puma (6.4.0) nio4r (~> 2.0) @@ -357,22 +378,27 @@ GEM rack (>= 2.1.0) rack-protection (3.0.4) rack + rack-session (1.0.1) + rack (< 3) 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 (1.0.0) + rack (< 3) + webrick + 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) @@ -387,20 +413,25 @@ GEM rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - 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) rb-readline (0.5.5) + rdoc (6.5.0) + psych (>= 4.0.0) regexp_parser (2.8.1) + reline (0.3.9) + io-console (~> 0.5) responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) @@ -473,6 +504,7 @@ GEM net-scp (>= 1.1.2) net-ssh (>= 2.8.0) stackprof (0.2.25) + stringio (3.0.8) swd (2.0.2) activesupport (>= 3) attr_required (>= 0.0.5) @@ -512,6 +544,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.8.1) websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -519,7 +552,7 @@ GEM will_paginate (4.0.0) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS x86_64-linux @@ -542,7 +575,7 @@ DEPENDENCIES counter_culture (~> 3.5) cssbundling-rails (~> 1.3.3) dalli (~> 3.2.6) - ddtrace (~> 1.14.0) + ddtrace (~> 1.15.0) delayed_job_active_record (~> 4.1.7) delayed_job_web (~> 1.4.4) devise (~> 4.9.2) @@ -584,7 +617,7 @@ DEPENDENCIES puma (~> 6.4.0) pundit (~> 2.3.1) rack-mini-profiler (~> 3.1.1) - rails (~> 7.0.8) + rails (~> 7.1.0) rails-controller-testing (~> 1.0.5) rails-i18n (~> 7.0.8) rb-readline (~> 0.5.5) diff --git a/README.md b/README.md index 72340e1079..eeb105e5bc 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/dodona-edu/dodona) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dodona-edu/dodona/test.yml?branch=main) ![Codecov](https://img.shields.io/codecov/c/github/dodona-edu/dodona) -[![Support chat](https://img.shields.io/static/v1?label=support%20chat&message=on%20matrix&color=informational)](https://matrix.to/#/#dodona-support:vanpetegem.me?via=vanpetegem.me) -[![General chat](https://img.shields.io/static/v1?label=general%20chat&message=on%20matrix&color=informational)](https://matrix.to/#/#dodona-general:vanpetegem.me?via=vanpetegem.me&via=matrix.org&via=beardhatcode.be) +[![Support chat](https://img.shields.io/static/v1?label=support%20chat&message=on%20slack&color=informational)](https://join.slack.com/t/dodona-edu/shared_invite/zt-24o2an3bp-fFR_TTM0fB_kmlCvkS2ckA) > Dodona is an online exercise platform for **learning to code**. It wants to teach students how to program in the most meaningful and effective way possible. Dodona acts as an **online co-teacher**, designed to give every student access to high quality education. The focus is on automatic corrections and giving **meaningful feedback** on the submitted solutions from students. diff --git a/app/controllers/api_tokens_controller.rb b/app/controllers/api_tokens_controller.rb index af92344118..a39b62e601 100644 --- a/app/controllers/api_tokens_controller.rb +++ b/app/controllers/api_tokens_controller.rb @@ -18,7 +18,7 @@ def create f.js { render 'create', locals: { toast: message, new_token: @token } } else errors = @token.errors.full_messages - errors << I18n.t('errors.models.api_token.attributes.not_permitted') unless can_create + errors << I18n.t('activerecord.errors.models.api_token.not_permitted') unless can_create message = errors.join(', ') f.html do redirect_back fallback_location: root_path, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 89f54ca91f..30b108dab7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -149,7 +149,7 @@ def sanitize(html) %w[svg g style circle line rect path polygon text] @attributes ||= Rails::Html::SafeListSanitizer.allowed_attributes.to_a + %w[style target data-bs-toggle data-parent data-tab data-line data-element id] + - %w[viewbox width height version style class transform id x y rx ry x1 y1 x2 y2 d points fill stroke stroke-width cx cy r font-size font-family font-weight font-variant] + %w[viewBox width height version style class transform id x y rx ry x1 y1 x2 y2 d points fill stroke stroke-width cx cy r font-size font-family font-weight font-variant] # Filters allowed tags and attributes sanitized = ActionController::Base.helpers.sanitize html, diff --git a/app/javascript/packs/application_pack.js b/app/javascript/packs/application_pack.js index 90ad7a54f9..06411ace4c 100644 --- a/app/javascript/packs/application_pack.js +++ b/app/javascript/packs/application_pack.js @@ -10,9 +10,9 @@ import "core-js/stable"; import "regenerator-runtime/runtime"; -import { start as startRails } from "@rails/ujs"; +import Rails from "@rails/ujs"; -startRails(); +Rails.start(); import { I18n } from "i18n/i18n"; window.I18n = new I18n(); diff --git a/app/models/activity.rb b/app/models/activity.rb index 9409641565..1541fecc4e 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -103,7 +103,6 @@ class Activity < ApplicationRecord scope :order_by_name, ->(direction) { reorder(Arel.sql("name_#{I18n.locale} IS NULL, name_#{I18n.locale} #{direction}")).order(path: direction) } scope :order_by_popularity, ->(direction) { reorder("series_count #{direction}") } - enum popularity: { unpopular: 0, neutral: 1, popular: 2, very_popular: 3 }, _prefix: true POPULARITY_THRESHOLDS = { unpopular: { min: 0, max: 2 }, neutral: { min: 3, max: 10 }, diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index c928cc4978..3b39cd7929 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -6,7 +6,7 @@
- <%= render partial: 'layouts/searchbar', locals: {labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], judges: @judges, popularity: Activity.popularities.keys, no_dropdown_for: ["judges"]} %> + <%= render partial: 'layouts/searchbar', locals: {labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], judges: @judges, popularity: Activity::POPULARITY_THRESHOLDS.keys, no_dropdown_for: ["judges"]} %>
<%= render partial: 'activities_table', locals: {activities: @activities} %>
diff --git a/app/views/series/edit.html.erb b/app/views/series/edit.html.erb index 13b5ef0a22..f317fe88bd 100644 --- a/app/views/series/edit.html.erb +++ b/app/views/series/edit.html.erb @@ -67,7 +67,7 @@

<%= t ".add_activities" %>

- <%= render partial: 'layouts/searchbar', locals: {baseUrl: available_activities_series_path(@series), eager: true, labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], popularity: Activity.popularities.keys, local_storage_key: 'seriesActivitySearch'} %> + <%= render partial: 'layouts/searchbar', locals: {baseUrl: available_activities_series_path(@series), eager: true, labels: @labels, programming_languages: @programming_languages, repositories: @repositories, activity_types: [ContentPage, Exercise], description_languages: ["en", "nl"], popularity: Activity::POPULARITY_THRESHOLDS.keys, local_storage_key: 'seriesActivitySearch'} %>
diff --git a/bin/rails b/bin/rails index 6fb4e4051c..efc0377492 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) +APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/setup b/bin/setup index 90700ac4f9..2cc4794838 100755 --- a/bin/setup +++ b/bin/setup @@ -2,10 +2,10 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do @@ -13,24 +13,24 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # Install JavaScript dependencies system! 'bin/yarn' # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system! 'bin/rails db:prepare' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index 7c9eda4730..bd4ddf1bd1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,18 @@ module Dodona class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 + + # ** Please read carefully, this must be configured in config/application.rb ** + # Change the format of the cache entry. + # Changing this default means that all new cache entries added to the cache + # will have a different format that is not supported by Rails 7.0 + # applications. + # Only change this value after your application is fully deployed to Rails 7.1 + # and you have no plans to rollback. + # When you're ready to change format, add this to `config/application.rb` (NOT + # this file): + config.active_support.cache_format_version = 7.0 config.dodona_email = 'dodona@ugent.be' # Configuration for the application, engines, and railties goes here. diff --git a/config/boot.rb b/config/boot.rb index 3cda23b4db..988a5ddc46 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environments/development.rb b/config/environments/development.rb index db09ee286f..3641cc6774 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -25,7 +25,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -33,6 +33,9 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. @@ -76,6 +79,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. @@ -112,6 +118,10 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + # Raise error when a before_action's only/except options reference missing actions + # Disable because application_controller.rb mentions a lot of actions that are only defined in some subclasses + config.action_controller.raise_on_missing_callback_actions = false + # Exception notifications config.middleware.use ExceptionNotification::Rack, ignore_if: ->(env, _exception) { env['HTTP_HOST'] == 'localhost:3000' || env['HTTP_HOST'] == 'dodona.localhost:3000' }, diff --git a/config/environments/production.rb b/config/environments/production.rb index 79e4e7cb61..11acfd200e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -57,6 +57,9 @@ # yet still be able to expire them through the digest params. config.assets.digest = true + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX @@ -69,16 +72,25 @@ # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Log to STDOUT by default + # config.logger = ActiveSupport::Logger.new(STDOUT) + # .tap { |logger| logger.formatter = ::Logger::Formatter.new } + # .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + # Use a different cache store in production. config.cache_store = :mem_cache_store, 'calliope.ugent.be', {namespace: :"2"} @@ -111,6 +123,12 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + config.middleware.use ExceptionNotification::Rack, ignore_crawlers: %w[Googlebot BingPreview bingbot Applebot], ignore_if: lambda { |env, exception| diff --git a/config/environments/test.rb b/config/environments/test.rb index b8d89cb031..70908d9747 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -17,12 +17,13 @@ config.action_controller.asset_host = nil - config.cache_classes = false + config.enable_reloading = true config.action_view.cache_template_loading = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = false # Configure public file server for tests with Cache-Control for performance. @@ -37,7 +38,7 @@ config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -67,6 +68,10 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + # Raise error when a before_action's only/except options reference missing actions + # Disable because application_controller.rb mentions a lot of actions that are only defined in some subclasses + config.action_controller.raise_on_missing_callback_actions = false + Delayed::Worker.delay_jobs = ->(job) { !%w[default exports git statistics].include?(job.queue) } config.submissions_storage_path = Rails.root.join('tmp/data/storage/submissions') diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 2cb708e72a..c9bf79d301 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -12,9 +12,5 @@ # Enable origin-checking CSRF mitigation. Previous versions had false. Rails.application.config.action_controller.forgery_protection_origin_check = false -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = false - # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = false diff --git a/package.json b/package.json index 310d7b04c1..04a771a5ae 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "@babel/preset-typescript": "^7.23.0", "@dodona/papyros": "^1.0.1", "@popperjs/core": "^2.11.8", - "@rails/activestorage": "^7.0.8", - "@rails/ujs": "^7.0.8", + "@rails/activestorage": "^7.1.0", + "@rails/ujs": "^7.1.0", "@types/d3": "^7.4.1", "babel-loader": "^9.1.3", "babel-plugin-macros": "^3.1.0", diff --git a/test/controllers/api_tokens_controller_test.rb b/test/controllers/api_tokens_controller_test.rb index cec8dc4576..fd295853ce 100644 --- a/test/controllers/api_tokens_controller_test.rb +++ b/test/controllers/api_tokens_controller_test.rb @@ -30,7 +30,7 @@ def create_request(attr_hash: nil) assert_difference('ApiToken.count', 0) do post user_api_tokens_url(:nl, @other_user), params: model_params(generate_attr_hash) end - assert_equal flash[:alert], I18n.t('errors.models.api_token.attributes.not_permitted') + assert_equal flash[:alert], I18n.t('activerecord.errors.models.api_token.not_permitted') end test 'should not be able to delete token from other user' do diff --git a/test/controllers/courses_controller_test.rb b/test/controllers/courses_controller_test.rb index 935892b1cd..4f5f9c8deb 100644 --- a/test/controllers/courses_controller_test.rb +++ b/test/controllers/courses_controller_test.rb @@ -836,7 +836,7 @@ def with_users_signed_in(users) assert_difference 'Course.count', -1 do delete course_url(@course) end - assert_includes response.body, courses_url + assert_redirected_to courses_url end test 'should not destroy course as course admin if too many submissions' do @@ -860,7 +860,7 @@ def with_users_signed_in(users) assert_difference 'Course.count', -1 do delete course_url(@course) end - assert_includes response.body, courses_url + assert_redirected_to courses_url end test 'super admins are able to view questions' do diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 6c4295191c..50697c5361 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -84,7 +84,9 @@ class ApplicationHelperTest < ActiveSupport::TestCase dirty_html = <<~HTML - + + + @@ -100,7 +102,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase test 'sanitize helper should allow a selection of svg tags' do dirty_html = <<~HTML - + diff --git a/test/runners/result_constructor_test.rb b/test/runners/result_constructor_test.rb index e3ba4203e5..451a01f665 100644 --- a/test/runners/result_constructor_test.rb +++ b/test/runners/result_constructor_test.rb @@ -1,6 +1,6 @@ require 'json' require 'test_helper' -require 'result_constructor' +require_relative '../../app/runners/result_constructor' class ResultConstructorTest < ActiveSupport::TestCase MINIMAL_FULL_S = diff --git a/test/testhelpers/git_helper.rb b/test/testhelpers/git_helper.rb index b1a266e7da..f523235607 100644 --- a/test/testhelpers/git_helper.rb +++ b/test/testhelpers/git_helper.rb @@ -1,7 +1,6 @@ require 'pathname' require 'fileutils' -require 'concerns/gitable' module Gitable def git_repository GitRepository.new full_path diff --git a/yarn.lock b/yarn.lock index baede02ccc..4398d6be00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1630,17 +1630,17 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== -"@rails/activestorage@^7.0.8": - version "7.0.8" - resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-7.0.8.tgz#7ea8a656b5621e0dc57f51e3ad2f06c3af30d3ea" - integrity sha512-CxPyCxTV0HIaZP8qqH11tkESNl8TrQsIAesAgeOXDOl0BkaN6nC0/Mq2/0ngezBu9CZbFzfHtP2g6Yl8BWkV8g== +"@rails/activestorage@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-7.1.0.tgz#6aeea30720f98ea25f790596862ac89251bcc05d" + integrity sha512-TYc3AkBaXgBlavODTHPgyaOMqt0MRkFlPCa7BiQJJyND17GYS7pP0lT0bgcDQgpuKMvsCdVxQaRwl6tzL5AW0g== dependencies: spark-md5 "^3.0.1" -"@rails/ujs@^7.0.8": - version "7.0.8" - resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.0.8.tgz#59853367d0827b3955d2c4bedfd5eba4a79d3422" - integrity sha512-tOQQBVH8LsUpGXqDnk+kaOGVsgZ8maHAhEiw3Git3p88q+c0Slgu47HuDnL6sVxeCfz24zbq7dOjsVYDiTpDIA== +"@rails/ujs@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.1.0.tgz#144ec54b1cc53aa24713cafc29bf8a8d52ac3d24" + integrity sha512-cO8+HREI8hhJDaFyzGCA4AL9/EotHYSTz1v7aQmfZmUdanx/ppXe+MPE4dly2/MtC6Ha6K2Dkzo7bkDGc46y6Q== "@sinonjs/commons@^1.7.0": version "1.8.3"
Head
Head