From 186a7d91c9d8c2c4e71b113fd7041751e96d16fd Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Tue, 14 Apr 2020 02:26:43 +0200 Subject: [PATCH] Upgrade Rails 5.2 -> 6.0 --- Gemfile | 5 +- Gemfile.lock | 118 +++++++++++------- bin/setup | 12 +- config/cable.yml | 2 +- config/environments/development.rb | 35 +----- .../initializers/content_security_policy.rb | 5 + config/puma.rb | 7 +- config/routes.rb | 2 +- config/spring.rb | 12 +- db/schema.rb | 12 +- 10 files changed, 106 insertions(+), 104 deletions(-) diff --git a/Gemfile b/Gemfile index 12d3010..31641d7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,13 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.2' +gem 'rails', '~> 6.0' gem 'bootsnap' +#gem 'webpacker' # To create variants (different sizes) of screenshot images saved in ActiveStorage -#gem 'image_processing' +gem 'image_processing' gem 'mini_magick' # Use Puma as the app server diff --git a/Gemfile.lock b/Gemfile.lock index 21d35c6..5d63f57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,51 +7,64 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (5.2.4.2) - actionpack (= 5.2.4.2) + actioncable (6.0.2.2) + actionpack (= 6.0.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.2) - actionpack (= 5.2.4.2) - actionview (= 5.2.4.2) - activejob (= 5.2.4.2) + actionmailbox (6.0.2.2) + actionpack (= 6.0.2.2) + activejob (= 6.0.2.2) + activerecord (= 6.0.2.2) + activestorage (= 6.0.2.2) + activesupport (= 6.0.2.2) + mail (>= 2.7.1) + actionmailer (6.0.2.2) + actionpack (= 6.0.2.2) + actionview (= 6.0.2.2) + activejob (= 6.0.2.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.2) - actionview (= 5.2.4.2) - activesupport (= 5.2.4.2) + actionpack (6.0.2.2) + actionview (= 6.0.2.2) + activesupport (= 6.0.2.2) 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.4.2) - activesupport (= 5.2.4.2) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.2.2) + actionpack (= 6.0.2.2) + activerecord (= 6.0.2.2) + activestorage (= 6.0.2.2) + activesupport (= 6.0.2.2) + nokogiri (>= 1.8.5) + actionview (6.0.2.2) + activesupport (= 6.0.2.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4.2) - activesupport (= 5.2.4.2) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.0.2.2) + activesupport (= 6.0.2.2) globalid (>= 0.3.6) - activemodel (5.2.4.2) - activesupport (= 5.2.4.2) - activerecord (5.2.4.2) - activemodel (= 5.2.4.2) - activesupport (= 5.2.4.2) - arel (>= 9.0) - activestorage (5.2.4.2) - actionpack (= 5.2.4.2) - activerecord (= 5.2.4.2) + activemodel (6.0.2.2) + activesupport (= 6.0.2.2) + activerecord (6.0.2.2) + activemodel (= 6.0.2.2) + activesupport (= 6.0.2.2) + activestorage (6.0.2.2) + actionpack (= 6.0.2.2) + activejob (= 6.0.2.2) + activerecord (= 6.0.2.2) marcel (~> 0.3.1) - activesupport (5.2.4.2) + activesupport (6.0.2.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + zeitwerk (~> 2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) ansi (1.5.0) - arel (9.0.0) babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) @@ -132,6 +145,9 @@ GEM hashie (4.1.0) i18n (1.8.2) concurrent-ruby (~> 1.0) + image_processing (1.10.3) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) jbuilder (2.10.0) activesupport (>= 5.0.0) jquery-rails (4.3.5) @@ -166,9 +182,9 @@ GEM mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.14.0) - minitest-rails (5.2.0) + minitest-rails (6.0.1) minitest (~> 5.10) - railties (~> 5.2.0) + railties (~> 6.0.0) minitest-rails-capybara (0.0.2) capybara minitest-rails @@ -237,18 +253,20 @@ GEM ruby-openid (>= 2.1.8) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.4.2) - actioncable (= 5.2.4.2) - actionmailer (= 5.2.4.2) - actionpack (= 5.2.4.2) - actionview (= 5.2.4.2) - activejob (= 5.2.4.2) - activemodel (= 5.2.4.2) - activerecord (= 5.2.4.2) - activestorage (= 5.2.4.2) - activesupport (= 5.2.4.2) + rails (6.0.2.2) + actioncable (= 6.0.2.2) + actionmailbox (= 6.0.2.2) + actionmailer (= 6.0.2.2) + actionpack (= 6.0.2.2) + actiontext (= 6.0.2.2) + actionview (= 6.0.2.2) + activejob (= 6.0.2.2) + activemodel (= 6.0.2.2) + activerecord (= 6.0.2.2) + activestorage (= 6.0.2.2) + activesupport (= 6.0.2.2) bundler (>= 1.3.0) - railties (= 5.2.4.2) + railties (= 6.0.2.2) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -260,12 +278,12 @@ GEM ruby-graphviz (~> 1.2) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (5.2.4.2) - actionpack (= 5.2.4.2) - activesupport (= 5.2.4.2) + railties (6.0.2.2) + actionpack (= 6.0.2.2) + activesupport (= 6.0.2.2) method_source rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) + thor (>= 0.20.3, < 2.0) rake (13.0.1) rb-fsevent (0.10.3) rb-inotify (0.10.1) @@ -281,6 +299,8 @@ GEM rexml ruby-openid (2.9.2) ruby-progressbar (1.10.1) + ruby-vips (2.0.17) + ffi (~> 1.9) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -336,11 +356,11 @@ GEM execjs (>= 0.3.0, < 3) warden (1.2.8) rack (>= 2.0.6) - web-console (3.7.0) - actionview (>= 5.0) - activemodel (>= 5.0) + web-console (4.0.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) bindex (>= 0.4.0) - railties (>= 5.0) + railties (>= 6.0.0) websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) @@ -349,6 +369,7 @@ GEM will_paginate (>= 3.0.3) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.3.0) PLATFORMS ruby @@ -367,6 +388,7 @@ DEPENDENCIES foundation-rails (~> 6.4) guard-minitest guard-rails + image_processing jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) @@ -384,7 +406,7 @@ DEPENDENCIES pg pg_search puma (~> 3.0) - rails (~> 5.2) + rails (~> 6.0) rails-erd sass-rails (~> 5.0) sdoc (~> 0.4.0) diff --git a/bin/setup b/bin/setup index 94fd4d7..5853b5e 100755 --- a/bin/setup +++ b/bin/setup @@ -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' diff --git a/config/cable.yml b/config/cable.yml index d89aa0b..4dde668 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -2,7 +2,7 @@ development: adapter: async test: - adapter: async + adapter: test production: adapter: redis diff --git a/config/environments/development.rb b/config/environments/development.rb index 2a4ea12..66df51f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,6 +16,7 @@ Rails.application.configure do # Run rails dev:cache to toggle caching. 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 = { @@ -27,7 +28,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. @@ -52,38 +53,10 @@ Rails.application.configure do # Suppress logger output for asset requests. config.assets.quiet = true - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. - # config.file_watcher = ActiveSupport::EventedFileUpdateChecker - - # DEB package repositories to parse when running "rake debshots:... tasks" - config.package_sources = [ - { - description: 'Development test files', type: 'apt', url: 'lib/tasks/files/', - architectures: ['i386', 'amd64'] - #components: ['main','restricted','universe','multiverse'] - } - ] - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true - - # Example file for development to avoid queries to online service - # config.ubuntu_reviews_api_url = 'test/files/ubuntu-review-api/cream' - # config.ubuntu_reviews_api_url = 'https://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/any/any/any/any/%s' - - config.images_path = Rails.root.join('public', 'screenshots') - - config.image_sizes = { - large: '800x600', - small: '160x120', - } - - # config.file_watcher = ActiveSupport::EventedFileUpdateChecker - - # Any action dealing with authentication should redirect to HTTPS - #config.to_prepare { Devise::SessionsController.force_ssl(port: 3001) } - + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index d3bcaa5..35d0f26 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -11,6 +11,8 @@ # policy.object_src :none # policy.script_src :self, :https # policy.style_src :self, :https +# # 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 # # policy.report_uri "/csp-violation-report-endpoint" @@ -19,6 +21,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 diff --git a/config/puma.rb b/config/puma.rb index b210207..5ed4437 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -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 3000. # @@ -19,7 +20,7 @@ environment ENV.fetch("RAILS_ENV") { "development" } 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). diff --git a/config/routes.rb b/config/routes.rb index e504b96..afc494a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -106,5 +106,5 @@ Rails.application.routes.draw do # resources :products # end - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end diff --git a/config/spring.rb b/config/spring.rb index 9fa7863..db5bf13 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -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" +) diff --git a/db/schema.rb b/db/schema.rb index 02aaf91..b617efa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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: 2020_04_13_210200) do +ActiveRecord::Schema.define(version: 2020_04_14_002409) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"