From ecfe0ea850d203e8144adab744c4b43263200902 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Wed, 30 Jun 2021 04:00:41 +0200 Subject: [PATCH] Bump rails and drop support for rails < 5.2 (EOL) --- Gemfile.lock | 55 +++++++++---------- bin/rails | 16 +++--- diaspora_federation-rails.gemspec | 2 +- test/dummy/bin/rails | 4 +- test/dummy/bin/rake | 4 ++ test/dummy/bin/setup | 25 +++++++++ test/dummy/config.ru | 4 +- test/dummy/config/application.rb | 11 ++-- test/dummy/config/boot.rb | 3 +- test/dummy/config/environments/development.rb | 20 ++++++- test/dummy/config/environments/production.rb | 24 ++++---- test/dummy/config/environments/test.rb | 15 ++++- .../initializers/filter_parameter_logging.rb | 4 +- 13 files changed, 125 insertions(+), 62 deletions(-) create mode 100755 test/dummy/bin/rake create mode 100755 test/dummy/bin/setup diff --git a/Gemfile.lock b/Gemfile.lock index de5088a..2d164c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ PATH valid (~> 1.0) diaspora_federation-json_schema (0.2.6) diaspora_federation-rails (0.2.6) - actionpack (>= 5, < 7) + actionpack (>= 5.2, < 7) diaspora_federation (= 0.2.6) diaspora_federation-test (0.2.6) diaspora_federation (= 0.2.6) @@ -19,38 +19,38 @@ PATH GEM remote: https://rubygems.org/ specs: - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (6.0.0) - activesupport (= 6.0.0) + actionview (6.1.4) + activesupport (= 6.1.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activesupport (6.0.0) + activesupport (6.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) - builder (3.2.3) + builder (3.2.4) byebug (11.1.3) coderay (1.1.3) - concurrent-ruby (1.1.5) + concurrent-ruby (1.1.9) crack (0.4.5) rexml - crass (1.0.5) + crass (1.0.6) diff-lcs (1.3) docile (1.4.0) - erubi (1.9.0) + erubi (1.10.0) ethon (0.12.0) ffi (>= 1.3.0) fabrication (2.20.2) @@ -80,7 +80,7 @@ GEM httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.7.0) + i18n (1.8.10) concurrent-ruby (~> 1.0) json-schema (2.8.1) addressable (>= 2.4) @@ -90,7 +90,7 @@ GEM listen (3.5.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.3.0) + loofah (2.10.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) macaddr (1.7.2) @@ -100,7 +100,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) mini_portile2 (2.5.3) - minitest (5.12.2) + minitest (5.14.4) multi_xml (0.6.0) multipart-post (2.1.1) nokogiri (1.11.7) @@ -141,12 +141,12 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 0.13) + thor (~> 1.0) rainbow (3.0.0) rake (13.0.3) rb-fsevent (0.11.0) @@ -211,11 +211,10 @@ GEM terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thor (1.1.0) - thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) unicode-display_width (1.7.0) uuid (2.3.9) macaddr (~> 1.0) @@ -225,7 +224,7 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) yard (0.9.26) - zeitwerk (2.2.0) + zeitwerk (2.4.2) PLATFORMS ruby diff --git a/bin/rails b/bin/rails index 4595731..6b5ee87 100755 --- a/bin/rails +++ b/bin/rails @@ -1,12 +1,14 @@ #!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. +# This command will automatically be run when you run "rails" with Rails gems +# installed from the root of your application. -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/diaspora_federation/engine', __FILE__) +ENGINE_ROOT = File.expand_path('..', __dir__) +ENGINE_PATH = File.expand_path('../lib/diaspora_federation/engine', __dir__) +APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -require 'rails/all' -require 'rails/engine/commands' +require "rails/all" +require "rails/engine/commands" diff --git a/diaspora_federation-rails.gemspec b/diaspora_federation-rails.gemspec index 625372d..72eed7d 100644 --- a/diaspora_federation-rails.gemspec +++ b/diaspora_federation-rails.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.required_ruby_version = "~> 2.5" - s.add_dependency "actionpack", ">= 5", "< 7" + s.add_dependency "actionpack", ">= 5.2", "< 7" s.add_dependency "diaspora_federation", DiasporaFederation::VERSION end diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index 0739660..6fb4e40 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +require_relative "../config/boot" +require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100755 index 0000000..4fbf10b --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup new file mode 100755 index 0000000..bf08171 --- /dev/null +++ b/test/dummy/bin/setup @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +require "fileutils" + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # 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 "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 2cc53cf..2e03084 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -2,5 +2,7 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path("config/environment", __dir__) +require_relative "config/environment" + run Rails.application +Rails.application.load_server diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index dccc66d..f7d2554 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -27,9 +27,12 @@ module Dummy # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.0 - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") end end diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 55bd95c..593ee1f 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -2,6 +2,5 @@ # Set up gems listed in the Gemfile. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) -require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 652647a..70df74b 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # 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 @@ -33,8 +35,17 @@ Rails.application.configure do # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. @@ -45,4 +56,7 @@ Rails.application.configure do # Show the logging configuration on STDOUT config.show_log_configuration = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index b567c33..35b3954 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -25,7 +27,7 @@ Rails.application.configure do config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # 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 @@ -34,15 +36,9 @@ Rails.application.configure do # 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 - - # Set the logging destination(s) - config.log_to = %w[file] - - # Show the logging configuration on STDOUT - config.show_log_configuration = false + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [:request_id] @@ -61,11 +57,17 @@ Rails.application.configure do # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. - # require 'syslog/logger' + # require "syslog/logger" # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index bae3b39..18e193d 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/integer/time" + # 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 @@ -8,7 +10,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = false + config.cache_classes = 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 @@ -35,6 +37,15 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index 7a4f47b..3babc73 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -3,4 +3,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn +]