Upgrade to Rails 6.0 and apply new framework defaults

This commit is contained in:
Sebastian Serth
2021-05-10 22:04:49 +02:00
parent 3c4ff307af
commit 8378070bc2
25 changed files with 232 additions and 171 deletions

View File

@ -25,7 +25,7 @@ gem 'prometheus_exporter'
gem 'pry-byebug'
gem 'puma'
gem 'pundit'
gem 'rails', '5.2.6'
gem 'rails', '6.0.3.7'
gem 'rails_admin'
gem 'rails-i18n'
gem 'rails-timeago'
@ -35,7 +35,7 @@ gem 'rubytree'
gem 'rubyzip'
gem 'sass-rails'
gem 'slim-rails'
gem 'sorcery'
gem 'sorcery' # Causes a deprecation warning in Rails 6.0+, see: https://github.com/Sorcery/sorcery/pull/255
gem 'telegraf'
gem 'tubesock', git: 'https://github.com/gosukiwi/tubesock', branch: 'patch-1' # Switch to a fork which is compatible with Rails 5
gem 'turbolinks'

View File

@ -22,55 +22,68 @@ GEM
remote: https://rubygems.org/
specs:
ZenTest (4.12.0)
actioncable (5.2.6)
actionpack (= 5.2.6)
actioncable (6.0.3.7)
actionpack (= 6.0.3.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
actionmailbox (6.0.3.7)
actionpack (= 6.0.3.7)
activejob (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
mail (>= 2.7.1)
actionmailer (6.0.3.7)
actionpack (= 6.0.3.7)
actionview (= 6.0.3.7)
activejob (= 6.0.3.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.6)
actionview (= 5.2.6)
activesupport (= 5.2.6)
actionpack (6.0.3.7)
actionview (= 6.0.3.7)
activesupport (= 6.0.3.7)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.6)
activesupport (= 5.2.6)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.7)
actionpack (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
nokogiri (>= 1.8.5)
actionview (6.0.3.7)
activesupport (= 6.0.3.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.6)
activesupport (= 5.2.6)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.7)
activesupport (= 6.0.3.7)
globalid (>= 0.3.6)
activemodel (5.2.6)
activesupport (= 5.2.6)
activemodel (6.0.3.7)
activesupport (= 6.0.3.7)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (5.2.6)
activemodel (= 5.2.6)
activesupport (= 5.2.6)
arel (>= 9.0)
activestorage (5.2.6)
actionpack (= 5.2.6)
activerecord (= 5.2.6)
activerecord (6.0.3.7)
activemodel (= 6.0.3.7)
activesupport (= 6.0.3.7)
activestorage (6.0.3.7)
actionpack (= 6.0.3.7)
activejob (= 6.0.3.7)
activerecord (= 6.0.3.7)
marcel (~> 1.0.0)
activesupport (5.2.6)
activesupport (6.0.3.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
amq-protocol (2.3.2)
arel (9.0.0)
ast (2.4.2)
autotest (5.0.0)
minitest-autotest (~> 1.0)
@ -132,7 +145,7 @@ GEM
erubi (1.10.0)
eventmachine (1.2.7)
excon (0.81.0)
execjs (2.7.0)
execjs (2.8.0)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
@ -237,10 +250,6 @@ GEM
nokogiri (1.11.3)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
nokogiri (1.11.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.11.3-x86_64-linux)
racc (~> 1.4)
nyan-cat-formatter (0.12.0)
rspec (>= 2.99, >= 2.14.2, < 4)
oauth (0.5.6)
@ -283,18 +292,20 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.6)
actioncable (= 5.2.6)
actionmailer (= 5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
activemodel (= 5.2.6)
activerecord (= 5.2.6)
activestorage (= 5.2.6)
activesupport (= 5.2.6)
rails (6.0.3.7)
actioncable (= 6.0.3.7)
actionmailbox (= 6.0.3.7)
actionmailer (= 6.0.3.7)
actionpack (= 6.0.3.7)
actiontext (= 6.0.3.7)
actionview (= 6.0.3.7)
activejob (= 6.0.3.7)
activemodel (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
bundler (>= 1.3.0)
railties (= 5.2.6)
railties (= 6.0.3.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
@ -305,9 +316,9 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (5.1.3)
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
railties (>= 6.0.0, < 7)
rails-timeago (2.19.1)
actionpack (>= 3.1)
activesupport (>= 3.1)
@ -323,12 +334,12 @@ GEM
rails (>= 5.0, < 7)
remotipart (~> 1.3)
sassc-rails (>= 1.3, < 3)
railties (5.2.6)
actionpack (= 5.2.6)
activesupport (= 5.2.6)
railties (6.0.3.7)
actionpack (= 6.0.3.7)
activesupport (= 6.0.3.7)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.3)
ransack (2.4.2)
@ -467,11 +478,11 @@ GEM
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (2.0.0)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 5.0)
railties (>= 6.0.0)
webmock (3.12.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
@ -491,11 +502,10 @@ GEM
will_paginate (3.3.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.2)
PLATFORMS
ruby
x86_64-darwin-20
x86_64-linux
DEPENDENCIES
autotest
@ -536,7 +546,7 @@ DEPENDENCIES
puma
pundit
rack-mini-profiler
rails (= 5.2.6)
rails (= 6.0.3.7)
rails-controller-testing
rails-i18n
rails-timeago

View File

@ -1,6 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
@ -9,24 +8,25 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime 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')
# Install JavaScript dependencies if using Yarn
# Install JavaScript dependencies
# system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

View File

@ -10,8 +10,8 @@ require 'telegraf/rails'
module CodeOcean
class Application < Rails::Application
# Initialize configuration defaults
config.load_defaults 5.2
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
@ -27,9 +27,21 @@ module CodeOcean
# config.i18n.default_locale = :de
config.i18n.available_locales = [:de, :en]
config.autoload_paths << Rails.root.join('lib')
config.eager_load_paths << Rails.root.join('lib')
config.assets.precompile += %w( markdown-buttons.png )
# Add inflection for Zeitwerk
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'IO'
end
extra_paths = %W[
#{config.root}/lib
]
# Add generators, they don't have a module structure that matches their directory structure.
extra_paths << "#{config.root}/lib/generators"
config.add_autoload_paths_to_load_path = false
config.autoload_paths += extra_paths
config.eager_load_paths += extra_paths
config.action_cable.mount_path = '/cable'

View File

@ -1,8 +1,8 @@
development:
adapter: postgresql
adapter: async
test:
adapter: postgresql
adapter: test
staging:
adapter: postgresql

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true
Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = true
# Settings specified here will take precedence over those in config/application.rb.
config.web_console.whitelisted_ips = '192.168.0.0/16'
@ -20,8 +18,9 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp/caching-dev.txt').exist?
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
@ -33,7 +32,7 @@ Rails.application.configure do
config.cache_store = :null_store
end
# Store uploaded files on the local file system (see config/storage.yml for options)
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Don't care if the mailer can't send.
@ -55,26 +54,22 @@ Rails.application.configure do
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
config.action_view.raise_on_missing_translations = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
config.action_view.raise_on_missing_translations = true
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem and might not
# work within a Vagrant environment.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.file_watcher = ActiveSupport::FileUpdateChecker
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# If the evented file watcher doesn't work (in Vagrant), use another one:
# config.file_watcher = ActiveSupport::FileUpdateChecker
end

View File

@ -1,8 +1,6 @@
# frozen_string_literal: true
Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
@ -27,20 +25,13 @@ Rails.application.configure do
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
# Compress JavaScript and CSS using a preprocessor.
config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
@ -48,10 +39,10 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options)
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Mount Action Cable outside main process or domain
# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
@ -69,9 +60,9 @@ Rails.application.configure do
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "code_ocean_#{Rails.env}"
# config.active_job.queue_name_prefix = "code_ocean_production"
config.action_mailer.perform_caching = false
@ -101,4 +92,25 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end

View File

@ -1,13 +1,14 @@
# frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
config.cache_classes = false
# 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
@ -24,6 +25,7 @@ Rails.application.configure do
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :memory_store
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
@ -31,7 +33,7 @@ Rails.application.configure do
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
config.action_mailer.perform_caching = false
@ -47,10 +49,6 @@ Rails.application.configure do
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# config.logger = Logger.new($stdout)
# Set log level
# config.log_level = :DEBUG
end

View File

@ -1,3 +1,7 @@
# frozen_string_literal: true
require 'code_ocean/config'
CodeOcean::Config.new(:action_mailer).read.each do |key, value|
CodeOcean::Application.config.action_mailer.send(:"#{key}=", value.respond_to?(:symbolize_keys) ? value.symbolize_keys : value)
end

View File

@ -1,20 +1,19 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
Rails.application.config.tap do |config|
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Add additional assets to the asset load path.
# config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# config.assets.precompile += %w( admin.js admin.css )
end
# 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( markdown-buttons.png )
# Disable concurrent asset compilation to prevent segfault # https://github.com/sass/sassc-ruby/issues/197
# Reproduce: `rake assets:clobber`, `rake assets:precompile`. If the command succeeds, it worked

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
@ -11,10 +13,7 @@
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
#
# # You need to allow webpack-dev-server host as allowed origin for connect-src.
# # This can be done in Rails 5.2+ for development environment in the CSP initializer
# # config/initializers/content_security_policy.rb with a snippet like this:
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
# # Specify URI for violation reports
@ -24,6 +23,9 @@
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true
require 'docker_client'
DockerClient.initialize_environment unless Rails.env.test? && `which docker`.blank?
return if Rake.application.top_level_tasks.to_s.include?('db:')
if ApplicationRecord.connection.tables.present? &&
DockerContainerPool.config[:active]
# no op
end

View File

@ -1 +1,5 @@
Docker::Container.send(:include, DockerContainerMixin)
# frozen_string_literal: true
require 'docker_container_mixin'
Docker::Container.include DockerContainerMixin

View File

@ -1,9 +1,13 @@
# frozen_string_literal: true
require 'code_ocean/config'
return unless CodeOcean::Config.new(:code_ocean).read[:prometheus_exporter][:enabled] && !defined?(::Rails::Console)
return if %w[db: assets:].any? { |task| Rake.application.top_level_tasks.to_s.include?(task) }
# Add metric callbacks to all models
ApplicationRecord.include Prometheus::Record
ActiveSupport.on_load :active_record do
include Prometheus::Record
end
# Initialization is performed in config/application.rb

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
RailsAdmin.config do |config|
### Popular gems integration

View File

@ -4,8 +4,9 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 7000.
#
@ -15,8 +16,11 @@ port ENV.fetch("PORT") { 7000 }
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).

View File

@ -1,6 +1,6 @@
%w(
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
Spring.watch(
".ruby-version",
".rbenv-vars",
"tmp/restart.txt",
"tmp/caching-dev.txt"
)

View File

@ -0,0 +1,12 @@
# frozen_string_literal: true
# This migration comes from active_storage (originally 20180723000244)
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
def up
return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
if table_exists?(:active_storage_blobs)
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
end
end
end

View File

@ -2,15 +2,15 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_04_26_113125) do
ActiveRecord::Schema.define(version: 2021_05_10_174452) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@ -481,7 +481,6 @@ ActiveRecord::Schema.define(version: 2021_04_26_113125) do
add_foreign_key "exercise_tips", "exercise_tips", column: "parent_exercise_tip_id"
add_foreign_key "exercise_tips", "exercises"
add_foreign_key "exercise_tips", "tips"
add_foreign_key "request_for_comments", "submissions", name: "request_for_comments_submissions_id_fk"
add_foreign_key "remote_evaluation_mappings", "study_groups"
add_foreign_key "submissions", "study_groups"
add_foreign_key "tips", "file_types"

View File

@ -2,21 +2,21 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.3",
"@rails/webpacker": "^5.3.0",
"@sentry/browser": "^6.2.1",
"@sentry/browser": "^6.3.6",
"bootstrap": "^4.6.0",
"bootswatch": "^5.0.0",
"bootswatch": "^4.6.0",
"chosen-js": "^1.8.7",
"d3": "^6.7.0",
"d3-tip": "^0.9.1",
"highlight.js": "^10.7.1",
"jquery": "^3.5.1",
"highlight.js": "^10.7.2",
"jquery": "^3.6.0",
"jquery-ui": "^1.12.1",
"jquery-ujs": "^1.2.2",
"jstree": "^3.3.11",
"opensans-webkit": "^1.1.0",
"popper.js": "^1.16.1",
"sortablejs": "^1.13.0",
"underscore": "^1.13.0",
"underscore": "^1.13.1",
"vis": "^4.21.0",
"webpack-merge": "^5.7.3"
},

View File

@ -54,7 +54,7 @@ describe SubmissionsController do
expect_status(200)
it 'sets the correct filename' do
expect(response.headers['Content-Disposition']).to eq("attachment; filename=\"#{file.name_with_extension}\"")
expect(response.headers['Content-Disposition']).to include("attachment; filename=\"#{file.name_with_extension}\"")
end
end
end
@ -72,7 +72,7 @@ describe SubmissionsController do
expect_status(200)
it 'sets the correct filename' do
expect(response.headers['Content-Disposition']).to eq("attachment; filename=\"#{file.name_with_extension}\"")
expect(response.headers['Content-Disposition']).to include("attachment; filename=\"#{file.name_with_extension}\"")
end
end
@ -85,7 +85,7 @@ describe SubmissionsController do
expect_status(200)
it 'sets the correct filename' do
expect(response.headers['Content-Disposition']).to eq("attachment; filename=\"#{file.name_with_extension}\"")
expect(response.headers['Content-Disposition']).to include("attachment; filename=\"#{file.name_with_extension}\"")
end
end
end

View File

@ -7,12 +7,18 @@ describe 'seeds' do
before do
CodeOcean::Application.load_tasks
# We want to execute the seeds for the dev environment against the test database
allow(Rails).to receive(:env) { 'development'.inquiry }
allow(ActiveRecord::Base).to receive(:establish_connection).and_call_original
allow(ActiveRecord::Base).to receive(:establish_connection).with(:development) {
ActiveRecord::Base.establish_connection(:test)
}
end
describe 'execute db:seed' do
it 'collects the test results' do
expect { seed }.not_to raise_error(StandardError)
expect { seed }.not_to raise_error
end
end
end

View File

@ -78,7 +78,8 @@ describe FileTree do
let(:files) { FactoryBot.build_list(:file, 10, context: nil, path: 'foo/bar/baz') }
it 'creates a root node' do
expect_any_instance_of(Tree::TreeNode).to receive(:initialize).with(file_tree.send(:root_label))
# Instead of checking #initialize on the parent, we validate #set_as_root!
expect(file_tree).to receive(:set_as_root!).and_call_original
file_tree.send(:initialize)
end

View File

@ -17,7 +17,7 @@ end
def expect_content_type(content_type)
it "responds with content type '#{content_type}'" do
expect([response.content_type, response.headers['Content-Type']]).to include(content_type)
expect([response.media_type, response.headers['Content-Type']]).to include(content_type)
end
end

View File

@ -941,7 +941,7 @@
webpack-cli "^3.3.12"
webpack-sources "^1.4.3"
"@sentry/browser@^6.2.1":
"@sentry/browser@^6.3.6":
version "6.3.6"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.3.6.tgz#bba07033efded6c844de88dcc47f99548a29afed"
integrity sha512-l4323jxuBOArki6Wf+EHes39IEyJ2Zj/CIUaTY7GWh7CntpfHQAfFmZWQw3Ozq+ka1u8lVp25RPhb4Wng3azNA==
@ -1535,10 +1535,10 @@ bootstrap@^4.6.0:
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.6.0.tgz#97b9f29ac98f98dfa43bf7468262d84392552fd7"
integrity sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw==
bootswatch@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/bootswatch/-/bootswatch-5.0.0.tgz#da1c9b2ca697163975683824ffbaa425ee3d4f40"
integrity sha512-IXmloGK/UjGvs22+3sSht4zK2dXK8EWV9j6NzLp/7EoVwi0Rg3to1Y99tAi16h4uHtoE32ci08Hx9yhhoCKKYA==
bootswatch@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/bootswatch/-/bootswatch-4.6.0.tgz#295237ed0e118decb3e3543f2ac14e9bb8ae48ea"
integrity sha512-Yr6YqFBC8jwTzoJoLViYlvO97IhPWGqZEm+6FXHfD/G6gbUok6sZkdXxdh4Zb6iCGEwr9p7zGCn38yKQD/bh2Q==
brace-expansion@^1.1.7:
version "1.1.11"
@ -3525,7 +3525,7 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
highlight.js@^10.7.1:
highlight.js@^10.7.2:
version "10.7.2"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.2.tgz#89319b861edc66c48854ed1e6da21ea89f847360"
integrity sha512-oFLl873u4usRM9K63j4ME9u3etNF0PLiJhSQ8rdfuL51Wn3zkD6drf9ZW0dOzjnZI22YYG24z30JcmfCZjMgYg==
@ -4095,7 +4095,7 @@ jquery-ujs@^1.2.2:
dependencies:
jquery ">=1.8.0"
jquery@>=1.8.0, jquery@>=1.9.1, jquery@^3.5.1:
jquery@>=1.8.0, jquery@>=1.9.1, jquery@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==
@ -6860,7 +6860,7 @@ unbox-primitive@^1.0.0:
has-symbols "^1.0.2"
which-boxed-primitive "^1.0.2"
underscore@^1.13.0:
underscore@^1.13.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1"
integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==