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
-
Head
+
+
Head
+
@@ -100,7 +102,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase
test 'sanitize helper should allow a selection of svg tags' do
dirty_html = <<~HTML
-