20300: Rails 6.0 app:update
authorTom Clegg <tom@curii.com>
Mon, 25 Sep 2023 18:36:56 +0000 (14:36 -0400)
committerTom Clegg <tom@curii.com>
Fri, 29 Sep 2023 14:14:14 +0000 (10:14 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

17 files changed:
services/api/bin/rails
services/api/bin/rake
services/api/bin/setup
services/api/config/application.rb
services/api/config/boot.rb
services/api/config/environment.rb
services/api/config/initializers/application_controller_renderer.rb
services/api/config/initializers/assets.rb
services/api/config/initializers/backtrace_silencers.rb
services/api/config/initializers/content_security_policy.rb
services/api/config/initializers/cookies_serializer.rb
services/api/config/initializers/filter_parameter_logging.rb
services/api/config/initializers/inflections.rb
services/api/config/initializers/mime_types.rb
services/api/config/initializers/new_framework_defaults_6_0.rb [new file with mode: 0644]
services/api/config/initializers/wrap_parameters.rb
services/api/config/locales/en.yml

index 5f594d1186a41b49419e7bcb8a8cae680a82d0a4..073966023774750c90fe9c89910c769a92da604b 100755 (executable)
@@ -1,9 +1,4 @@
 #!/usr/bin/env ruby
-
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 APP_PATH = File.expand_path('../config/application', __dir__)
 require_relative '../config/boot'
 require 'rails/commands'
index 87484df469df441d64def584e483fc4076313b95..17240489f64832c9ce080088e27780d3dc3ee29a 100755 (executable)
@@ -1,9 +1,4 @@
 #!/usr/bin/env ruby
-
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 require_relative '../config/boot'
 require 'rake'
 Rake.application.run
index c9142b942ed12a848a4497a01ad7393dfd78d370..0e39e8cb132e93010c81a850f0e7b3c5cde20c4a 100755 (executable)
@@ -1,11 +1,5 @@
 #!/usr/bin/env ruby
-
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 require 'fileutils'
-include FileUtils
 
 # path to your application root.
 APP_ROOT = File.expand_path('..', __dir__)
@@ -14,8 +8,9 @@ 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 =='
@@ -24,11 +19,11 @@ chdir APP_ROOT do
 
   # 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'
index dcd77d7b6b85c2bf4e3204343f8ccab912364dd5..587a09d4e08f44ef93d9933eb28f420f408b29ec 100644 (file)
@@ -5,41 +5,23 @@
 require_relative 'boot'
 
 require "rails"
-# Pick only the frameworks we need:
+# Pick the frameworks you want:
 require "active_model/railtie"
 require "active_job/railtie"
 require "active_record/railtie"
+# 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"
-# Skipping the following:
-# * ActionCable (new in Rails 5.0) as it adds '/cable' routes that we're not using
-# * ActiveStorage (new in Rails 5.1)
 
-require 'digest'
-
-module Kernel
-  def suppress_warnings
-    verbose_orig = $VERBOSE
-    begin
-      $VERBOSE = nil
-      yield
-    ensure
-      $VERBOSE = verbose_orig
-    end
-  end
-end
-
-if defined?(Bundler)
-  suppress_warnings do
-    # If you precompile assets before deploying to production, use this line
-    Bundler.require(*Rails.groups(:assets => %w(development test)))
-    # If you want your assets lazily compiled in production, use this line
-    # Bundler.require(:default, :assets, Rails.env)
-  end
-end
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
 
 if ENV["ARVADOS_RAILS_LOG_TO_STDOUT"]
   Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
@@ -50,42 +32,30 @@ module Server
 
     require_relative "arvados_config.rb"
 
-    # 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.
-
-    # Custom directories with classes and modules you want to be autoloadable.
-    # config.autoload_paths += %W(#{config.root}/extras)
+    # Initialize configuration defaults for originally generated Rails version.
+    config.load_defaults 5.0
 
-    # Only load the plugins named here, in the order given (default is alphabetical).
-    # :all can be used as a placeholder for all plugins not explicitly named.
-    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+    # 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.
 
-    # Activate observers that should always be running.
-    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+    # We use db/structure.sql instead of db/schema.rb.
     config.active_record.schema_format = :sql
 
-    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
-    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
-    # config.i18n.default_locale = :de
-
-    # Configure sensitive parameters which will be filtered from the log file.
-    config.filter_parameters += [:password]
-
-    # Load entire application at startup.
     config.eager_load = true
 
     config.active_support.test_order = :sorted
 
+    # container_request records can contain arbitrary data structures
+    # in mounts.*.content, so rails must not munge them.
     config.action_dispatch.perform_deep_munge = false
-
+    
     # force_ssl's redirect-to-https feature doesn't work when the
     # client supplies a port number, and prevents arvados-controller
     # from connecting to Rails internally via plain http.
     config.ssl_options = {redirect: false}
 
-    I18n.enforce_available_locales = false
-
     # Before using the filesystem backend for Rails.cache, check
     # whether we own the relevant directory. If we don't, using it is
     # likely to either fail or (if we're root) pollute it and cause
index 8087911837bf64f32323b6fa568f49a32575c927..30f5120df6986349c532c8ece3c170726118a703 100644 (file)
@@ -1,8 +1,3 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
-# Set up gems listed in the Gemfile.
 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
 
 require 'bundler/setup' # Set up gems listed in the Gemfile.
index cd706940a389752fd6263bb32fc82a057fc3c583..426333bb46978d897be4cc6fac77b9fcaacf59d0 100644 (file)
@@ -1,9 +1,5 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
-# Load the rails application
+# Load the Rails application.
 require_relative 'application'
 
-# Initialize the rails application
+# Initialize the Rails application.
 Rails.application.initialize!
index 525d6adf95f5ef587601c75817132c6c2b4af1fb..89d2efab2ba659d7814a7665a99f7f8d7429a072 100644 (file)
@@ -1,7 +1,3 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
 
 # ActiveSupport::Reloader.to_prepare do
index f02c87b73143fc0e01427ca2ff56e198c5cd2611..fe48fc34ee221419425f67157d0e0e99bad55a38 100644 (file)
@@ -1,15 +1,12 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # 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'
 
-# 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 )
index b9c6bceef5fc33dd25446258850994ade8862115..59385cdf379bd06a8d2326dcd4de6d5cd5d3f5b0 100644 (file)
@@ -1,7 +1,3 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
 
 # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
index 853ecdeec47d9ca9b6b5f4160e13d6c27fd14130..41c43016f1deb08ce1d511c5ac80bd62123e0872 100644 (file)
@@ -1,7 +1,3 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
 
 # Define an application-wide content security policy
@@ -23,6 +19,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
index 5409f55c0be0f2a0f98088e7bcc32f4e7cbf195d..5a6a32d371fe575acf9f87e2ab7e8ae4d0f11e69 100644 (file)
@@ -1,9 +1,5 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
 
 # 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
index f26d0ad223aeb2768f27cc906a739275d008409d..4a994e1e7bb7ce28dcec98bad48b9a891d7dec51 100644 (file)
@@ -1,7 +1,3 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
 
 # Configure sensitive parameters which will be filtered from the log file.
index 50bd0d5f557b6eae56d654bf5a700c82933760d1..8fee195a91d537cac10e40aebd859fa28ec28921 100644 (file)
@@ -4,15 +4,21 @@
 
 # Be sure to restart your server when you modify this file.
 
-# Add new inflection rules using the following format
-# (all these examples are active by default):
-# ActiveSupport::Inflector.inflections do |inflect|
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
 #   inflect.plural /^(ox)$/i, '\1en'
 #   inflect.singular /^(ox)en/i, '\1'
 #   inflect.irregular 'person', 'people'
 #   inflect.uncountable %w( fish sheep )
 # end
 
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+#   inflect.acronym 'RESTful'
+# end
+
 ActiveSupport::Inflector.inflections do |inflect|
   inflect.plural(/^([Ss]pecimen)$/i, '\1s')
   inflect.singular(/^([Ss]pecimen)s?/i, '\1')
index 36683cc2469f7e5ed9ce5ee12b87c6b659b36e6f..dc1899682b01c3a6d9673faf746e235fb64fc4d2 100644 (file)
@@ -1,9 +1,4 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
 
 # Add new mime types for use in respond_to blocks:
 # Mime::Type.register "text/richtext", :rtf
-# Mime::Type.register_alias "text/html", :iphone
diff --git a/services/api/config/initializers/new_framework_defaults_6_0.rb b/services/api/config/initializers/new_framework_defaults_6_0.rb
new file mode 100644 (file)
index 0000000..92240ef
--- /dev/null
@@ -0,0 +1,45 @@
+# 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
+
+# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
+# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
+
+# 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
+
+# When assigning to a collection of attachments declared via `has_many_attached`, replace existing
+# attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
+# Rails.application.config.active_storage.replace_on_assign_to_many = true
+
+# 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"
+
+# Enable the same cache key to be reused when the object being cached of type
+# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
+# of the relation's cache key into the cache version to support recycling cache key.
+# Rails.application.config.active_record.collection_cache_versioning = true
index 6fb9786504ea5247982f342ac7dfc6d426486b46..bbfc3961bffef15dabb35fe0de4c409d6efb58c5 100644 (file)
@@ -1,9 +1,5 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
 # Be sure to restart your server when you modify this file.
-#
+
 # This file contains settings for ActionController::ParamsWrapper which
 # is enabled by default.
 
@@ -12,7 +8,7 @@ ActiveSupport.on_load(:action_controller) do
   wrap_parameters format: [:json]
 end
 
-# Disable root element in JSON by default.
-ActiveSupport.on_load(:active_record) do
-  self.include_root_in_json = false
-end
+# To enable root element in JSON for ActiveRecord objects.
+ActiveSupport.on_load(:active_record) do
+#   self.include_root_in_json = true
+end
index e6a62cb837cd8776b1542b1ef11a151f3fb7ddee..cf9b342d0aebfa248437d33d7a720b1a1116608a 100644 (file)
@@ -1,9 +1,33 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
 #
-# SPDX-License-Identifier: AGPL-3.0
-
-# Sample localization file for English. Add more files in this directory for other locales.
-# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+# To use the locales, use `I18n.t`:
+#
+#     I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+#     <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+#     I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+#   'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at https://guides.rubyonrails.org/i18n.html.
 
 en:
   hello: "Hello world"