Просмотр исходного кода

Maintenance: Update rails from 7.0 to 7.1

Co-authored-by: Mantas Masalskis <mm@zammad.com>
Martin Gruner 6 месяцев назад
Родитель
Сommit
d73a27d6e0

+ 1 - 1
.gitlab/ci/browser/__templates__.yml

@@ -22,7 +22,7 @@
         bundle exec rake zammad:ci:test:prepare[with_elasticsearch] zammad:setup:auto_wizard[contrib/auto_wizard_browser_test.json] zammad:ci:app:start
         echo -e "\\e[0Ksection_end:`date +%s`:zammad_ci_test_prepare\\r\\e[0K"
       fi
-      bundle exec rails test --fail-fast test/browser --profile
+      bundle exec rails test --fail-fast test/browser
 
 .template_browser-core_chrome:
   extends:

+ 0 - 3
.gitlab/ci/test/unit.yml

@@ -1,9 +1,6 @@
 .template_unit:
   extends:
     - .job_rules_default
-  variables:
-    # Teach minitest to output information about the slowest tests
-    TESTOPTS: '--profile'
   script:
     - !reference [.scripts, zammad_db_init]
     - bundle exec rake test:units

+ 1 - 3
Gemfile

@@ -4,13 +4,12 @@ source 'https://rubygems.org'
 
 # core - base
 ruby '3.2.4'
-gem 'rails', '~> 7.0.8'
+gem 'rails', '~> 7.1.4'
 
 # core - rails additions
 gem 'activerecord-import'
 gem 'activerecord-session_store'
 gem 'bootsnap', require: false
-gem 'composite_primary_keys'
 gem 'json'
 gem 'parallel'
 
@@ -207,7 +206,6 @@ gem 'listen'
 group :development, :test do
 
   # test frameworks
-  gem 'minitest-profile', require: false
   gem 'rails-controller-testing'
   gem 'rspec-rails'
   gem 'rspec-retry'

+ 95 - 70
Gemfile.lock

@@ -32,59 +32,64 @@ GEM
       simple_po_parser (~> 1.1.6)
     aasm (5.5.0)
       concurrent-ruby (~> 1.0)
-    actioncable (7.0.8.4)
-      actionpack (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+    actioncable (7.1.4)
+      actionpack (= 7.1.4)
+      activesupport (= 7.1.4)
       nio4r (~> 2.0)
       websocket-driver (>= 0.6.1)
-    actionmailbox (7.0.8.4)
-      actionpack (= 7.0.8.4)
-      activejob (= 7.0.8.4)
-      activerecord (= 7.0.8.4)
-      activestorage (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+      zeitwerk (~> 2.6)
+    actionmailbox (7.1.4)
+      actionpack (= 7.1.4)
+      activejob (= 7.1.4)
+      activerecord (= 7.1.4)
+      activestorage (= 7.1.4)
+      activesupport (= 7.1.4)
       mail (>= 2.7.1)
       net-imap
       net-pop
       net-smtp
-    actionmailer (7.0.8.4)
-      actionpack (= 7.0.8.4)
-      actionview (= 7.0.8.4)
-      activejob (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+    actionmailer (7.1.4)
+      actionpack (= 7.1.4)
+      actionview (= 7.1.4)
+      activejob (= 7.1.4)
+      activesupport (= 7.1.4)
       mail (~> 2.5, >= 2.5.4)
       net-imap
       net-pop
       net-smtp
-      rails-dom-testing (~> 2.0)
-    actionpack (7.0.8.4)
-      actionview (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
-      rack (~> 2.0, >= 2.2.4)
+      rails-dom-testing (~> 2.2)
+    actionpack (7.1.4)
+      actionview (= 7.1.4)
+      activesupport (= 7.1.4)
+      nokogiri (>= 1.8.5)
+      racc
+      rack (>= 2.2.4)
+      rack-session (>= 1.0.1)
       rack-test (>= 0.6.3)
-      rails-dom-testing (~> 2.0)
-      rails-html-sanitizer (~> 1.0, >= 1.2.0)
-    actiontext (7.0.8.4)
-      actionpack (= 7.0.8.4)
-      activerecord (= 7.0.8.4)
-      activestorage (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+      rails-dom-testing (~> 2.2)
+      rails-html-sanitizer (~> 1.6)
+    actiontext (7.1.4)
+      actionpack (= 7.1.4)
+      activerecord (= 7.1.4)
+      activestorage (= 7.1.4)
+      activesupport (= 7.1.4)
       globalid (>= 0.6.0)
       nokogiri (>= 1.8.5)
-    actionview (7.0.8.4)
-      activesupport (= 7.0.8.4)
+    actionview (7.1.4)
+      activesupport (= 7.1.4)
       builder (~> 3.1)
-      erubi (~> 1.4)
-      rails-dom-testing (~> 2.0)
-      rails-html-sanitizer (~> 1.1, >= 1.2.0)
-    activejob (7.0.8.4)
-      activesupport (= 7.0.8.4)
+      erubi (~> 1.11)
+      rails-dom-testing (~> 2.2)
+      rails-html-sanitizer (~> 1.6)
+    activejob (7.1.4)
+      activesupport (= 7.1.4)
       globalid (>= 0.3.6)
-    activemodel (7.0.8.4)
-      activesupport (= 7.0.8.4)
-    activerecord (7.0.8.4)
-      activemodel (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+    activemodel (7.1.4)
+      activesupport (= 7.1.4)
+    activerecord (7.1.4)
+      activemodel (= 7.1.4)
+      activesupport (= 7.1.4)
+      timeout (>= 0.4.0)
     activerecord-import (1.8.1)
       activerecord (>= 4.2)
     activerecord-session_store (2.1.0)
@@ -94,17 +99,21 @@ GEM
       multi_json (~> 1.11, >= 1.11.2)
       rack (>= 2.0.8, < 4)
       railties (>= 6.1)
-    activestorage (7.0.8.4)
-      actionpack (= 7.0.8.4)
-      activejob (= 7.0.8.4)
-      activerecord (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+    activestorage (7.1.4)
+      actionpack (= 7.1.4)
+      activejob (= 7.1.4)
+      activerecord (= 7.1.4)
+      activesupport (= 7.1.4)
       marcel (~> 1.0)
-      mini_mime (>= 1.1.0)
-    activesupport (7.0.8.4)
+    activesupport (7.1.4)
+      base64
+      bigdecimal
       concurrent-ruby (~> 1.0, >= 1.0.2)
+      connection_pool (>= 2.2.5)
+      drb
       i18n (>= 1.6, < 2)
       minitest (>= 5.1)
+      mutex_m
       tzinfo (~> 2.0)
     acts_as_list (1.2.2)
       activerecord (>= 6.1)
@@ -176,9 +185,8 @@ GEM
       coffee-script-source
       execjs
     coffee-script-source (1.12.2)
-    composite_primary_keys (14.0.9)
-      activerecord (~> 7.0.2)
     concurrent-ruby (1.3.4)
+    connection_pool (2.4.1)
     cose (1.3.0)
       cbor (~> 0.5.9)
       openssl-signature_algorithm (~> 1.0)
@@ -203,6 +211,7 @@ GEM
     domain_name (0.6.20240107)
     doorkeeper (5.7.1)
       railties (>= 5)
+    drb (2.2.1)
     dry-cli (1.0.0)
     dry-core (1.0.1)
       concurrent-ruby (~> 1.0)
@@ -301,6 +310,10 @@ GEM
     inflection (1.0.0)
     iniparse (1.5.0)
     interception (0.5)
+    io-console (0.7.2)
+    irb (1.14.0)
+      rdoc (>= 4.0.0)
+      reline (>= 0.4.2)
     jmespath (1.6.2)
     json (2.7.2)
     jwt (2.3.0)
@@ -344,12 +357,12 @@ GEM
     mini_mime (1.1.5)
     mini_portile2 (2.8.7)
     minitest (5.25.1)
-    minitest-profile (0.0.2)
     msgpack (1.7.2)
     multi_json (1.15.0)
     multi_xml (0.7.1)
       bigdecimal (~> 3.1)
     multipart-post (2.4.1)
+    mutex_m (0.2.0)
     mysql2 (0.5.6)
     naught (1.1.0)
     nestful (1.1.4)
@@ -462,6 +475,8 @@ GEM
       pry (~> 0.13)
     pry-theme (1.3.1)
       coderay (~> 1.1)
+    psych (5.1.2)
+      stringio
     public_suffix (5.1.1)
     puma (6.4.2)
       nio4r (~> 2.0)
@@ -481,22 +496,27 @@ GEM
       rack (~> 2.2, >= 2.2.4)
     rack-proxy (0.7.7)
       rack
+    rack-session (1.0.2)
+      rack (< 3)
     rack-test (2.1.0)
       rack (>= 1.3)
-    rails (7.0.8.4)
-      actioncable (= 7.0.8.4)
-      actionmailbox (= 7.0.8.4)
-      actionmailer (= 7.0.8.4)
-      actionpack (= 7.0.8.4)
-      actiontext (= 7.0.8.4)
-      actionview (= 7.0.8.4)
-      activejob (= 7.0.8.4)
-      activemodel (= 7.0.8.4)
-      activerecord (= 7.0.8.4)
-      activestorage (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
+    rackup (1.0.0)
+      rack (< 3)
+      webrick
+    rails (7.1.4)
+      actioncable (= 7.1.4)
+      actionmailbox (= 7.1.4)
+      actionmailer (= 7.1.4)
+      actionpack (= 7.1.4)
+      actiontext (= 7.1.4)
+      actionview (= 7.1.4)
+      activejob (= 7.1.4)
+      activemodel (= 7.1.4)
+      activerecord (= 7.1.4)
+      activestorage (= 7.1.4)
+      activesupport (= 7.1.4)
       bundler (>= 1.15.0)
-      railties (= 7.0.8.4)
+      railties (= 7.1.4)
     rails-controller-testing (1.0.5)
       actionpack (>= 5.0.1.rc1)
       actionview (>= 5.0.1.rc1)
@@ -508,21 +528,26 @@ GEM
     rails-html-sanitizer (1.6.0)
       loofah (~> 2.21)
       nokogiri (~> 1.14)
-    railties (7.0.8.4)
-      actionpack (= 7.0.8.4)
-      activesupport (= 7.0.8.4)
-      method_source
+    railties (7.1.4)
+      actionpack (= 7.1.4)
+      activesupport (= 7.1.4)
+      irb
+      rackup (>= 1.0.0)
       rake (>= 12.2)
-      thor (~> 1.0)
-      zeitwerk (~> 2.5)
+      thor (~> 1.0, >= 1.2.2)
+      zeitwerk (~> 2.6)
     rainbow (3.1.1)
     rake (13.2.1)
     rb-fsevent (0.11.2)
     rb-inotify (0.10.1)
       ffi (~> 1.0)
     rchardet (1.8.0)
+    rdoc (6.7.0)
+      psych (>= 4.0.0)
     redis (4.8.1)
     regexp_parser (2.9.2)
+    reline (0.5.10)
+      io-console (~> 0.5)
     rexml (3.3.7)
     rotp (6.3.0)
     rspec-core (3.13.1)
@@ -633,6 +658,7 @@ GEM
       actionpack (>= 6.1)
       activesupport (>= 6.1)
       sprockets (>= 3.0.0)
+    stringio (3.1.1)
     systemu (2.6.5)
     tcr (0.4.0)
     telegram-bot-ruby (2.0.0)
@@ -704,6 +730,7 @@ GEM
       addressable (>= 2.8.0)
       crack (>= 0.3.2)
       hashdiff (>= 0.4.0, < 2.0.0)
+    webrick (1.8.1)
     websocket (1.2.11)
     websocket-driver (0.7.6)
       websocket-extensions (>= 0.1.0)
@@ -751,7 +778,6 @@ DEPENDENCIES
   chunky_png
   clearbit
   coffee-rails
-  composite_primary_keys
   csv
   daemons
   dalli
@@ -781,7 +807,6 @@ DEPENDENCIES
   mail
   messagebird-rest
   mime-types
-  minitest-profile
   mysql2
   net-ftp
   net-http
@@ -815,7 +840,7 @@ DEPENDENCIES
   pundit
   pundit-matchers
   rack-attack
-  rails (~> 7.0.8)
+  rails (~> 7.1.4)
   rails-controller-testing
   rchardet (>= 1.8.0)
   redis (>= 3, < 5)

+ 1 - 1
app/graphql/gql/zammad_schema.rb

@@ -103,7 +103,7 @@ class Gql::ZammadSchema < GraphQL::Schema
     extensions = {
       type: err.class.name,
     }
-    if Rails.env.development? || Rails.env.test?
+    if Rails.env.local?
       extensions[:backtrace] = Rails.backtrace_cleaner.clean(err.backtrace)
     end
 

+ 2 - 2
app/models/concerns/has_group_relation_definition.rb

@@ -5,8 +5,8 @@ module HasGroupRelationDefinition
 
   included do
 
-    self.table_name   = "groups_#{group_relation_model_identifier}s"
-    self.primary_keys = ref_key, :group_id, :access
+    self.table_name  = "groups_#{group_relation_model_identifier}s"
+    self.primary_key = ref_key, :group_id, :access
 
     belongs_to group_relation_model_identifier, optional: true
     belongs_to :group, optional: true

+ 8 - 2
app/models/knowledge_base/answer.rb

@@ -33,8 +33,14 @@ class KnowledgeBase::Answer < ApplicationModel
 
   acts_as_list scope: :category, top_of_list: 0
 
-  # provide consistent naming with KB category
-  alias_attribute :parent, :category
+  # Provide consistent naming with KB category
+  #
+  # Originally this used alias_attribute. But alias_attribute for relations for deprecated in Rails 7.1 and removed in 7.2
+  # However, alias_association was not merged in time for 7.2... So here is a workaround that will hopefully get removed in 7.3!
+  #
+  # Related PR: https://github.com/rails/rails/pull/49801
+  alias parent category
+  alias parent= category=
 
   alias assets_essential assets
 

+ 5 - 7
app/models/knowledge_base/answer/translation.rb

@@ -40,13 +40,11 @@ class KnowledgeBase::Answer::Translation < ApplicationModel
   def search_index_attribute_lookup(include_references: true)
     attrs = super
 
-    attrs.merge({
-                  title:      ActionController::Base.helpers.strip_tags(attrs['title']),
-                  content:    content&.search_index_attribute_lookup,
-                  scope_id:   answer.category_id,
-                  attachment: answer.attachments_for_search_index_attribute_lookup,
-                  tags:       answer.tag_list
-                })
+    attrs.merge('title'      => ActionController::Base.helpers.strip_tags(attrs['title']),
+                'content'    => content&.search_index_attribute_lookup,
+                'scope_id'   => answer.category_id,
+                'attachment' => answer.attachments_for_search_index_attribute_lookup,
+                'tags'       => answer.tag_list)
   end
 
   def inline_linked_objects

+ 3 - 4
bin/rails

@@ -1,5 +1,4 @@
 #!/usr/bin/env ruby
-APP_PATH = File.expand_path('../config/application', __dir__)
-require_relative '../config/boot'
-
-require 'rails/commands'
+APP_PATH = File.expand_path("../config/application", __dir__)
+require_relative "../config/boot"
+require "rails/commands"

+ 2 - 2
bin/rake

@@ -1,4 +1,4 @@
 #!/usr/bin/env ruby
-require_relative '../config/boot'
-require 'rake'
+require_relative "../config/boot"
+require "rake"
 Rake.application.run

Некоторые файлы не были показаны из-за большого количества измененных файлов