Browse Source

Maintenance: Updated to Rails 6.1.

Martin Gruner 3 years ago
parent
commit
d7b8b3662f

+ 2 - 2
Gemfile

@@ -4,7 +4,7 @@ source 'https://rubygems.org'
 
 # core - base
 ruby '2.7.4'
-gem 'rails', '~> 6.0.0'
+gem 'rails', '~> 6.1.0'
 
 # core - rails additions
 gem 'activerecord-import'
@@ -20,7 +20,7 @@ gem 'unicorn', group: :unicorn
 # core - supported ORMs
 gem 'activerecord-nulldb-adapter', group: :nulldb
 gem 'mysql2', group: :mysql
-gem 'pg', '0.21.0', group: :postgres
+gem 'pg', '~> 1.2.0', group: :postgres
 
 # core - asynchrous task execution
 gem 'daemons'

+ 74 - 70
Gemfile.lock

@@ -23,50 +23,52 @@ GEM
       simple_po_parser (~> 1.1.2)
     aasm (5.2.0)
       concurrent-ruby (~> 1.0)
-    actioncable (6.0.4.7)
-      actionpack (= 6.0.4.7)
+    actioncable (6.1.5)
+      actionpack (= 6.1.5)
+      activesupport (= 6.1.5)
       nio4r (~> 2.0)
       websocket-driver (>= 0.6.1)
-    actionmailbox (6.0.4.7)
-      actionpack (= 6.0.4.7)
-      activejob (= 6.0.4.7)
-      activerecord (= 6.0.4.7)
-      activestorage (= 6.0.4.7)
-      activesupport (= 6.0.4.7)
+    actionmailbox (6.1.5)
+      actionpack (= 6.1.5)
+      activejob (= 6.1.5)
+      activerecord (= 6.1.5)
+      activestorage (= 6.1.5)
+      activesupport (= 6.1.5)
       mail (>= 2.7.1)
-    actionmailer (6.0.4.7)
-      actionpack (= 6.0.4.7)
-      actionview (= 6.0.4.7)
-      activejob (= 6.0.4.7)
+    actionmailer (6.1.5)
+      actionpack (= 6.1.5)
+      actionview (= 6.1.5)
+      activejob (= 6.1.5)
+      activesupport (= 6.1.5)
       mail (~> 2.5, >= 2.5.4)
       rails-dom-testing (~> 2.0)
-    actionpack (6.0.4.7)
-      actionview (= 6.0.4.7)
-      activesupport (= 6.0.4.7)
-      rack (~> 2.0, >= 2.0.8)
+    actionpack (6.1.5)
+      actionview (= 6.1.5)
+      activesupport (= 6.1.5)
+      rack (~> 2.0, >= 2.0.9)
       rack-test (>= 0.6.3)
       rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.0, >= 1.2.0)
-    actiontext (6.0.4.7)
-      actionpack (= 6.0.4.7)
-      activerecord (= 6.0.4.7)
-      activestorage (= 6.0.4.7)
-      activesupport (= 6.0.4.7)
+    actiontext (6.1.5)
+      actionpack (= 6.1.5)
+      activerecord (= 6.1.5)
+      activestorage (= 6.1.5)
+      activesupport (= 6.1.5)
       nokogiri (>= 1.8.5)
-    actionview (6.0.4.7)
-      activesupport (= 6.0.4.7)
+    actionview (6.1.5)
+      activesupport (= 6.1.5)
       builder (~> 3.1)
       erubi (~> 1.4)
       rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.1, >= 1.2.0)
-    activejob (6.0.4.7)
-      activesupport (= 6.0.4.7)
+    activejob (6.1.5)
+      activesupport (= 6.1.5)
       globalid (>= 0.3.6)
-    activemodel (6.0.4.7)
-      activesupport (= 6.0.4.7)
-    activerecord (6.0.4.7)
-      activemodel (= 6.0.4.7)
-      activesupport (= 6.0.4.7)
+    activemodel (6.1.5)
+      activesupport (= 6.1.5)
+    activerecord (6.1.5)
+      activemodel (= 6.1.5)
+      activesupport (= 6.1.5)
     activerecord-import (1.3.0)
       activerecord (>= 4.2)
     activerecord-nulldb-adapter (0.8.0)
@@ -77,17 +79,19 @@ GEM
       multi_json (~> 1.11, >= 1.11.2)
       rack (>= 2.0.8, < 3)
       railties (>= 5.2.4.1)
-    activestorage (6.0.4.7)
-      actionpack (= 6.0.4.7)
-      activejob (= 6.0.4.7)
-      activerecord (= 6.0.4.7)
-      marcel (~> 1.0.0)
-    activesupport (6.0.4.7)
+    activestorage (6.1.5)
+      actionpack (= 6.1.5)
+      activejob (= 6.1.5)
+      activerecord (= 6.1.5)
+      activesupport (= 6.1.5)
+      marcel (~> 1.0)
+      mini_mime (>= 1.1.0)
+    activesupport (6.1.5)
       concurrent-ruby (~> 1.0, >= 1.0.2)
-      i18n (>= 0.7, < 2)
-      minitest (~> 5.1)
-      tzinfo (~> 1.1)
-      zeitwerk (~> 2.2, >= 2.2.2)
+      i18n (>= 1.6, < 2)
+      minitest (>= 5.1)
+      tzinfo (~> 2.0)
+      zeitwerk (~> 2.3)
     acts_as_list (1.0.4)
       activerecord (>= 4.2)
     addressable (2.8.0)
@@ -136,9 +140,9 @@ GEM
       coffee-script
       execjs
       json
-    composite_primary_keys (12.0.10)
-      activerecord (~> 6.0.0)
-    concurrent-ruby (1.1.9)
+    composite_primary_keys (13.0.3)
+      activerecord (~> 6.1.0)
+    concurrent-ruby (1.1.10)
     crack (0.4.5)
       rexml
     crass (1.0.6)
@@ -276,7 +280,7 @@ GEM
     logging (2.3.0)
       little-plugger (~> 1.1)
       multi_json (~> 1.14)
-    loofah (2.14.0)
+    loofah (2.15.0)
       crass (~> 1.0.2)
       nokogiri (>= 1.5.9)
     lumberjack (1.2.8)
@@ -363,10 +367,10 @@ GEM
       childprocess (>= 0.6.3, < 5)
       iniparse (~> 1.4)
       rexml (~> 3.2)
-    parallel (1.21.0)
+    parallel (1.22.0)
     parser (3.1.1.0)
       ast (~> 2.4.1)
-    pg (0.21.0)
+    pg (1.2.3)
     power_assert (2.0.1)
     pry (0.14.1)
       coderay (~> 1.1)
@@ -395,20 +399,20 @@ GEM
       rack
     rack-test (1.1.0)
       rack (>= 1.0, < 3)
-    rails (6.0.4.7)
-      actioncable (= 6.0.4.7)
-      actionmailbox (= 6.0.4.7)
-      actionmailer (= 6.0.4.7)
-      actionpack (= 6.0.4.7)
-      actiontext (= 6.0.4.7)
-      actionview (= 6.0.4.7)
-      activejob (= 6.0.4.7)
-      activemodel (= 6.0.4.7)
-      activerecord (= 6.0.4.7)
-      activestorage (= 6.0.4.7)
-      activesupport (= 6.0.4.7)
-      bundler (>= 1.3.0)
-      railties (= 6.0.4.7)
+    rails (6.1.5)
+      actioncable (= 6.1.5)
+      actionmailbox (= 6.1.5)
+      actionmailer (= 6.1.5)
+      actionpack (= 6.1.5)
+      actiontext (= 6.1.5)
+      actionview (= 6.1.5)
+      activejob (= 6.1.5)
+      activemodel (= 6.1.5)
+      activerecord (= 6.1.5)
+      activestorage (= 6.1.5)
+      activesupport (= 6.1.5)
+      bundler (>= 1.15.0)
+      railties (= 6.1.5)
       sprockets-rails (>= 2.0.0)
     rails-controller-testing (1.0.5)
       actionpack (>= 5.0.1.rc1)
@@ -419,12 +423,12 @@ GEM
       nokogiri (>= 1.6)
     rails-html-sanitizer (1.4.2)
       loofah (~> 2.3)
-    railties (6.0.4.7)
-      actionpack (= 6.0.4.7)
-      activesupport (= 6.0.4.7)
+    railties (6.1.5)
+      actionpack (= 6.1.5)
+      activesupport (= 6.1.5)
       method_source
-      rake (>= 0.8.7)
-      thor (>= 0.20.3, < 2.0)
+      rake (>= 12.2)
+      thor (~> 1.0)
     rainbow (3.1.1)
     raindrops (0.20.0)
     rake (13.0.6)
@@ -549,13 +553,13 @@ GEM
       multipart-post (~> 2.0)
       naught (~> 1.0)
       simple_oauth (~> 0.3.0)
-    tzinfo (1.2.9)
-      thread_safe (~> 0.1)
+    tzinfo (2.0.4)
+      concurrent-ruby (~> 1.0)
     uglifier (4.2.0)
       execjs (>= 0.3.0, < 3)
     unf (0.1.4)
       unf_ext
-    unf_ext (0.0.8)
+    unf_ext (0.0.8.1)
     unicode-display_width (2.1.0)
     unicorn (6.1.0)
       kgio (~> 2.6)
@@ -655,7 +659,7 @@ DEPENDENCIES
   omniauth-weibo-oauth2
   openssl
   overcommit
-  pg (= 0.21.0)
+  pg (~> 1.2.0)
   pry-rails
   pry-remote
   pry-rescue
@@ -664,7 +668,7 @@ DEPENDENCIES
   pundit
   pundit-matchers
   rack-livereload
-  rails (~> 6.0.0)
+  rails (~> 6.1.0)
   rails-controller-testing
   rb-fsevent
   rchardet (>= 1.8.0)

+ 9 - 0
app/controllers/application_controller/sets_headers.rb

@@ -46,3 +46,12 @@ module ApplicationController::SetsHeaders
     render plain: ''
   end
 end
+
+module ActionDispatch
+  class Response
+    def merge_and_normalize_cache_control!(...)
+      # Mutilate this Rails 6.1 method which does not allow us to specify
+      #   our custom Cache-Control header.
+    end
+  end
+end

+ 1 - 1
app/controllers/monitoring_controller.rb

@@ -249,7 +249,7 @@ curl http://localhost/api/v1/monitoring/status?token=XXX
       status[:last_created_at][key] = last&.created_at
     end
 
-    if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
+    if ActiveRecord::Base.connection_db_config.configuration_hash[:adapter] == 'postgresql'
       sql = 'SELECT SUM(CAST(coalesce(size, \'0\') AS INTEGER)) FROM stores'
       records_array = ActiveRecord::Base.connection.exec_query(sql)
       if records_array[0] && records_array[0]['sum']

+ 1 - 1
app/controllers/tickets_mass_controller.rb

@@ -55,7 +55,7 @@ class TicketsMassController < ApplicationController
 
     clean_params = Ticket.association_name_to_id_convert(params.require(:attributes))
     clean_params = Ticket.param_cleanup(clean_params, true)
-    clean_params.reject! { |_k, v| v.blank? }
+    clean_params.compact_blank!
 
     clean_params[:screen] = 'edit'
     clean_params.delete('number')

+ 4 - 2
app/controllers/users_controller.rb

@@ -775,7 +775,9 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
       return
     end
 
-    if ActiveStorage::Variant::WEB_IMAGE_CONTENT_TYPES.exclude?(file_full[:mime_type])
+    web_image_content_types = Rails.application.config.active_storage.web_image_content_types
+
+    if web_image_content_types.exclude?(file_full[:mime_type])
       render json: { error: __('The MIME type of the full-size image is invalid.') }, status: :unprocessable_entity
       return
     end
@@ -787,7 +789,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
       return
     end
 
-    if ActiveStorage::Variant::WEB_IMAGE_CONTENT_TYPES.exclude?(file_resize[:mime_type])
+    if web_image_content_types.exclude?(file_resize[:mime_type])
       render json: { error: __('The MIME type of the resized image is invalid.') }, status: :unprocessable_entity
       return
     end

+ 1 - 1
app/jobs/application_job.rb

@@ -5,7 +5,7 @@ class ApplicationJob < ActiveJob::Base
   include ApplicationJob::HasQueuingPriority
   include ApplicationJob::HasCustomLogging
 
-  ActiveJob::Logging::LogSubscriber.detach_from :active_job
+  ActiveJob::LogSubscriber.detach_from :active_job
 
   # See config/initializers/delayed_jobs_timeout_per_job.rb for details.
   def self.max_run_time

+ 1 - 1
app/jobs/application_job/has_custom_logging.rb

@@ -10,7 +10,7 @@ class ApplicationJob
     # The custom version comes with two changes:
     # - Don't log info level lines
     # - Log (info) that an ActiveJob was not enqueued in case there is already one queued with the same ActiveJobLock
-    class LogSubscriber < ActiveJob::Logging::LogSubscriber
+    class LogSubscriber < ActiveJob::LogSubscriber
 
       # ATTENTION: Uncomment this line to enable info logging again
       def info(...); end

+ 2 - 2
app/models/channel/email_parser.rb

@@ -379,7 +379,7 @@ returns
   def self.sender_attributes(from)
     if from.is_a?(HashWithIndifferentAccess)
       from = SENDER_FIELDS.filter_map { |f| from[f] }
-                          .map(&:to_utf8).reject(&:blank?)
+                          .map(&:to_utf8).compact_blank
                           .partition { |address| address.match?(EMAIL_REGEX) }
                           .flatten.first
     end
@@ -696,7 +696,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
       'original-format'     => message.mime_type.eql?('text/html'),
       'Mime-Type'           => message.mime_type,
       'Charset'             => message.charset,
-    }.reject { |_, v| v.blank? }
+    }.compact_blank
 
     [{
       data:        body_text(message),

+ 9 - 5
bin/yarn

@@ -1,11 +1,15 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
 APP_ROOT = File.expand_path('..', __dir__)
 Dir.chdir(APP_ROOT) do
-  begin
-    exec "yarnpkg", *ARGV
-  rescue Errno::ENOENT
+  yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
+    select { |dir| File.expand_path(dir) != __dir__ }.
+    product(["yarn", "yarn.cmd", "yarn.ps1"]).
+    map { |dir, file| File.expand_path(file, dir) }.
+    find { |file| File.executable?(file) }
+
+  if yarn
+    exec yarn, *ARGV
+  else
     $stderr.puts "Yarn executable was not detected in the system."
     $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
     exit 1

Some files were not shown because too many files changed in this diff