# HG changeset patch # User nanaya # Date 1563086284 -32400 # Node ID f67f3ad50270e22c50f528233af97c36d3093f77 # Parent a35c2733552fa5f1b528e205c1b926aa2ffbf7fc Update to latest rails and gems diff -r a35c2733552f -r f67f3ad50270 Gemfile --- a/Gemfile Fri May 31 09:45:02 2019 +0900 +++ b/Gemfile Sun Jul 14 15:38:04 2019 +0900 @@ -1,6 +1,6 @@ source "https://rubygems.org" -rails_ver = "~> 5.2.0" +rails_ver = "~> 6.0.0.rc1" gem "actionview", rails_ver gem "railties", rails_ver gem "actionpack", rails_ver diff -r a35c2733552f -r f67f3ad50270 Gemfile.lock --- a/Gemfile.lock Fri May 31 09:45:02 2019 +0900 +++ b/Gemfile.lock Sun Jul 14 15:38:04 2019 +0900 @@ -1,58 +1,59 @@ GEM remote: https://rubygems.org/ specs: - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) + actionpack (6.0.0.rc1) + actionview (= 6.0.0.rc1) + activesupport (= 6.0.0.rc1) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.3) - activesupport (= 5.2.3) + actionview (6.0.0.rc1) + activesupport (= 6.0.0.rc1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activesupport (5.2.3) + activesupport (6.0.0.rc1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + zeitwerk (~> 2.1, >= 2.1.4) addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) - async (1.17.1) + async (1.20.1) console (~> 1.0) nio4r (~> 2.3) timers (~> 4.1) - async-container (0.10.2) + async-container (0.14.1) async (~> 1.0) async-io (~> 1.4) process-group - async-http (0.41.2) - async (~> 1.14) - async-io (~> 1.18) - protocol-http (~> 0.5.0) - protocol-http1 (~> 0.7.0) - protocol-http2 (~> 0.3.0) - async-io (1.23.1) + async-http (0.46.4) + async (~> 1.19) + async-io (~> 1.24) + protocol-http (~> 0.10.0) + protocol-http1 (~> 0.8.0) + protocol-http2 (~> 0.9.0) + async-io (1.24.0) async (~> 1.14) buftok (0.2.0) - build-environment (1.10.1) + build-environment (1.11.0) builder (3.2.3) concurrent-ruby (1.1.5) - console (1.2.4) + console (1.4.0) crass (1.0.4) - domain_name (0.5.20180417) + domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) equalizer (0.0.11) erubi (1.8.0) - falcon (0.31.0) + falcon (0.33.11) async (~> 1.13) - async-container (~> 0.10.0) - async-http (~> 0.41.0) + async-container (~> 0.14.0) + async-http (~> 0.46.0) async-io (~> 1.22) - build-environment (~> 1.6) + build-environment (~> 1.11) localhost (~> 1.1) rack (>= 1.0) samovar (~> 2.1) @@ -81,24 +82,27 @@ minitest (5.11.3) multipart-post (2.1.1) naught (1.1.0) - newrelic_rpm (6.4.0.356) - nio4r (2.3.1) + newrelic_rpm (6.5.0.357) + nio4r (2.4.0) + nio4r (2.4.0-java) nokogiri (1.10.3) mini_portile2 (~> 2.4.0) nokogiri (1.10.3-java) nokogiri (1.10.3-x86-mingw32) mini_portile2 (~> 2.4.0) process-group (1.1.0) - protocol-hpack (1.0.0) - protocol-http (0.5.0) - protocol-http1 (0.7.0) + protocol-hpack (1.4.1) + protocol-http (0.10.0) + protocol-http1 (0.8.3) protocol-http (~> 0.5) - protocol-http2 (0.3.0) - protocol-hpack (~> 1.0) + protocol-http2 (0.9.3) + protocol-hpack (~> 1.4) protocol-http (~> 0.2) - public_suffix (3.1.0) - puma (3.12.1) - puma (3.12.1-java) + public_suffix (3.1.1) + puma (4.0.1) + nio4r (~> 2.0) + puma (4.0.1-java) + nio4r (~> 2.0) rack (2.0.7) rack-test (1.1.0) rack (>= 1.0, < 3) @@ -107,12 +111,12 @@ nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + railties (6.0.0.rc1) + actionpack (= 6.0.0.rc1) + activesupport (= 6.0.0.rc1) method_source rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) + thor (>= 0.20.3, < 2.0) rake (12.3.2) redis (4.1.2) redis-actionpack (5.0.2) @@ -159,6 +163,7 @@ unf_ext unf (0.1.4-java) unf_ext (0.0.7.6) + zeitwerk (2.1.8) PLATFORMS java @@ -166,12 +171,12 @@ x86-mingw32 DEPENDENCIES - actionpack (~> 5.2.0) - actionview (~> 5.2.0) + actionpack (~> 6.0.0.rc1) + actionview (~> 6.0.0.rc1) falcon newrelic_rpm puma - railties (~> 5.2.0) + railties (~> 6.0.0.rc1) redis redis-rails redis-store diff -r a35c2733552f -r f67f3ad50270 bin/setup --- a/bin/setup Fri May 31 09:45:02 2019 +0900 +++ b/bin/setup Sun Jul 14 15:38:04 2019 +0900 @@ -1,34 +1,25 @@ #!/usr/bin/env ruby -require "pathname" -require "fileutils" -include FileUtils +require 'fileutils' # path to your application root. -APP_ROOT = Pathname.new File.expand_path("../../", __FILE__) +APP_ROOT = File.expand_path('..', __dir__) 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") - - # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' - # end - - puts "\n== Preparing database ==" - system! "bin/rails db:setup" + 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" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' end diff -r a35c2733552f -r f67f3ad50270 config/application.rb --- a/config/application.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/application.rb Sun Jul 14 15:38:04 2019 +0900 @@ -1,4 +1,4 @@ -require_relative "boot" +require_relative 'boot' require "rails" # Pick the frameworks you want: @@ -8,12 +8,15 @@ # require "active_storage/engine" require "action_controller/railtie" # require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" require "action_view/railtie" # require "action_cable/engine" # require "sprockets/railtie" require "rails/test_unit/railtie" -require_relative "config_init" +require_relative 'config_init' +ENV['RAILS_LOG_TO_STDOUT'] = '1' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -22,11 +25,12 @@ module Rsstweet class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # 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. + config.middleware.delete ActionDispatch::HostAuthorization config.middleware.delete ActionDispatch::Cookies - # this isn't actually used but railties checks this variable during boot. config.secret_key_base = "herp a derp" config.session_store :disabled diff -r a35c2733552f -r f67f3ad50270 config/boot.rb --- a/config/boot.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/boot.rb Sun Jul 14 15:38:04 2019 +0900 @@ -1,3 +1,3 @@ -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 'bundler/setup' # Set up gems listed in the Gemfile. diff -r a35c2733552f -r f67f3ad50270 config/environment.rb --- a/config/environment.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/environment.rb Sun Jul 14 15:38:04 2019 +0900 @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative "application" +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff -r a35c2733552f -r f67f3ad50270 config/environments/development.rb --- a/config/environments/development.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/environments/development.rb Sun Jul 14 15:38:04 2019 +0900 @@ -13,36 +13,26 @@ config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. - if Rails.root.join("tmp/caching-dev.txt").exist? + # 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.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=172800" + 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false - # config.cache_store = :null_store + config.cache_store = :null_store end - # Don't care if the mailer can't send. - # config.action_mailer.raise_delivery_errors = false - - # config.action_mailer.perform_caching = false - # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations. - # config.active_record.migration_error = :page_load - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - # config.assets.debug = 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, diff -r a35c2733552f -r f67f3ad50270 config/environments/production.rb --- a/config/environments/production.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/environments/production.rb Sun Jul 14 15:38:04 2019 +0900 @@ -14,18 +14,13 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - - # Compress JavaScripts and CSS. - # 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 - - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + 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' @@ -34,13 +29,6 @@ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Action Cable endpoint configuration - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] - - # Don't mount Action Cable in the main server process. - # config.action_cable.mount_path = nil - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -49,19 +37,14 @@ config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [:request_id] + config.log_tags = [ :request_id ] # 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 = "rsstweet_#{Rails.env}" - # config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false + # config.active_job.queue_name_prefix = "rsstweet_production" # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). @@ -77,12 +60,30 @@ # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - # if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - # end + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end - # 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 diff -r a35c2733552f -r f67f3ad50270 config/environments/test.rb --- a/config/environments/test.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/environments/test.rb Sun Jul 14 15:38:04 2019 +0900 @@ -1,10 +1,11 @@ +# 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 # Do not eager load code on boot. This avoids loading your whole application @@ -15,28 +16,23 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=3600" + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - # config.action_mailer.perform_caching = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - # config.action_mailer.delivery_method = :test # 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 end diff -r a35c2733552f -r f67f3ad50270 config/initializers/application_controller_renderer.rb --- a/config/initializers/application_controller_renderer.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/initializers/application_controller_renderer.rb Sun Jul 14 15:38:04 2019 +0900 @@ -1,6 +1,8 @@ # Be sure to restart your server when you modify this file. -# ApplicationController.renderer.defaults.merge!( -# http_host: 'example.org', -# https: false -# ) +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff -r a35c2733552f -r f67f3ad50270 config/initializers/assets.rb --- a/config/initializers/assets.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/initializers/assets.rb Sun Jul 14 15:38:04 2019 +0900 @@ -1,11 +1,12 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -# Rails.application.config.assets.version = "1.0" +# Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff -r a35c2733552f -r f67f3ad50270 config/initializers/content_security_policy.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/content_security_policy.rb Sun Jul 14 15:38:04 2019 +0900 @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# 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 +# Rails.application.config.content_security_policy_report_only = true diff -r a35c2733552f -r f67f3ad50270 config/initializers/cookies_serializer.rb --- a/config/initializers/cookies_serializer.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/initializers/cookies_serializer.rb Sun Jul 14 15:38:04 2019 +0900 @@ -2,4 +2,4 @@ # Specify a serializer for the signed and encrypted cookie jars. # Valid options are :json, :marshal, and :hybrid. -# Rails.application.config.action_dispatch.cookies_serializer = :marshal +Rails.application.config.action_dispatch.cookies_serializer = :json diff -r a35c2733552f -r f67f3ad50270 config/initializers/new_framework_defaults_6_0.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/new_framework_defaults_6_0.rb Sun Jul 14 15:38:04 2019 +0900 @@ -0,0 +1,33 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 6.0 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Don't force requests from old versions of IE to be UTF-8 encoded. +# Rails.application.config.action_view.default_enforce_utf8 = false + +# Embed purpose and expiry metadata inside signed and encrypted +# cookies for increased security. +# +# This option is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.0. +# Rails.application.config.action_dispatch.use_cookies_with_metadata = true + +# Return false instead of self when enqueuing is aborted from a callback. +# Rails.application.config.active_job.return_false_on_aborted_enqueue = true + +# Send Active Storage analysis and purge jobs to dedicated queues. +# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis +# Rails.application.config.active_storage.queues.purge = :active_storage_purge + +# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. +# +# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), +# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. +# If you send mail in the background, job workers need to have a copy of +# MailDeliveryJob to ensure all delivery jobs are processed properly. +# Make sure your entire app is migrated and stable on 6.0 before using this setting. +# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" diff -r a35c2733552f -r f67f3ad50270 config/initializers/wrap_parameters.rb --- a/config/initializers/wrap_parameters.rb Fri May 31 09:45:02 2019 +0900 +++ b/config/initializers/wrap_parameters.rb Sun Jul 14 15:38:04 2019 +0900 @@ -5,10 +5,5 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters :format => [:json] + wrap_parameters format: [:json] end - -# To enable root element in JSON for ActiveRecord objects. -# ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true -# end