Browse Source

Maintenance: Updated to Rails 6.0.4 and the new Zeitwerk autoloader.

This changes the minimum supported version of PostgreSQL to 9.3.
Thorsten Eckel 3 years ago
parent
commit
ca56de3648

+ 1 - 1
.gitlab-ci.yml

@@ -45,7 +45,7 @@ variables:
 # as a key for the cache to avoid cache growth and incompatibilities between
 # the gems. Search hook: 2.6.6 (change it when updating the Ruby version too)
 cache:
-  key: "centos7ruby266"
+  key: "centos7ruby266rails6"
   paths:
     - vendor/ruby
     # ATTENTION: This should be a dedicated cache only used in the job "TODO".

+ 11 - 0
.gitlab/ci/pre.yml

@@ -21,6 +21,17 @@ shellcheck:
   script:
     - shellcheck -S warning $(find . -name "*.sh" -o -name "functions" | grep -v "/vendor/")
 
+zeitwerk_check:
+  <<: *template_pre
+  extends:
+    - .tags_docker
+    - .services_postgresql
+  script:
+    - bundle install -j $(nproc) --path vendor
+    - bundle exec ruby script/build/database_config.rb
+    - bundle exec rake zammad:db:init
+    - bundle exec rails zeitwerk:check
+
 coffeelint:
   <<: *template_pre
   script:

+ 1 - 3
.rubocop/default.yml

@@ -15,9 +15,7 @@ AllCops:
   NewCops: enable
   DisplayCopNames: true
   Exclude:
-    - 'bin/rails'
-    - 'bin/rake'
-    - 'bin/spring'
+    - 'bin/*'
     - 'db/schema.rb'
     - 'vendor/**/*'
     - 'node_modules/**/*'

+ 6 - 6
.rubocop/todo.yml

@@ -61,8 +61,6 @@ Metrics/AbcSize:
     - 'app/controllers/recent_view_controller.rb'
     - 'app/controllers/reports_controller.rb'
     - 'app/controllers/search_controller.rb'
-    - 'app/controllers/sessions/collection_base.rb'
-    - 'app/controllers/sessions/collection_ticket.rb'
     - 'app/controllers/sessions_controller.rb'
     - 'app/controllers/settings_controller.rb'
     - 'app/controllers/text_modules_controller.rb'
@@ -321,6 +319,8 @@ Metrics/AbcSize:
     - 'lib/service/geo_calendar/zammad.rb'
     - 'lib/service/geo_ip/zammad.rb'
     - 'lib/service/geo_location/gmaps.rb'
+    - 'lib/session_helper/collection_base.rb'
+    - 'lib/session_helper/collection_ticket.rb'
     - 'lib/sessions.rb'
     - 'lib/sessions/backend/activity_stream.rb'
     - 'lib/sessions/backend/base.rb'
@@ -478,8 +478,6 @@ Metrics/CyclomaticComplexity:
     - 'app/controllers/organizations_controller.rb'
     - 'app/controllers/reports_controller.rb'
     - 'app/controllers/search_controller.rb'
-    - 'app/controllers/sessions/collection_base.rb'
-    - 'app/controllers/sessions/collection_ticket.rb'
     - 'app/controllers/sessions_controller.rb'
     - 'app/controllers/ticket_articles_controller.rb'
     - 'app/controllers/tickets_controller.rb'
@@ -638,6 +636,8 @@ Metrics/CyclomaticComplexity:
     - 'lib/secure_mailing/smime/incoming.rb'
     - 'lib/sequencer/unit/import/zendesk/sub_sequence/base.rb'
     - 'lib/service/geo_ip/zammad.rb'
+    - 'lib/session_helper/collection_base.rb'
+    - 'lib/session_helper/collection_ticket.rb'
     - 'lib/sessions.rb'
     - 'lib/sessions/backend/activity_stream.rb'
     - 'lib/sessions/backend/ticket_overview_list.rb'
@@ -715,8 +715,6 @@ Metrics/PerceivedComplexity:
     - 'app/controllers/organizations_controller.rb'
     - 'app/controllers/reports_controller.rb'
     - 'app/controllers/search_controller.rb'
-    - 'app/controllers/sessions/collection_base.rb'
-    - 'app/controllers/sessions/collection_ticket.rb'
     - 'app/controllers/sessions_controller.rb'
     - 'app/controllers/ticket_articles_controller.rb'
     - 'app/controllers/tickets_controller.rb'
@@ -865,6 +863,8 @@ Metrics/PerceivedComplexity:
     - 'lib/search_index_backend.rb'
     - 'lib/secure_mailing/smime/incoming.rb'
     - 'lib/service/geo_ip/zammad.rb'
+    - 'lib/session_helper/collection_base.rb'
+    - 'lib/session_helper/collection_ticket.rb'
     - 'lib/sessions.rb'
     - 'lib/sessions/backend/activity_stream.rb'
     - 'lib/sessions/backend/ticket_overview_list.rb'

+ 1 - 1
Gemfile

@@ -4,7 +4,7 @@ source 'https://rubygems.org'
 
 # core - base
 ruby '2.6.6'
-gem 'rails', '5.2.4.6'
+gem 'rails', '6.0.4'
 
 # core - rails additions
 gem 'activerecord-import'

+ 77 - 65
Gemfile.lock

@@ -49,41 +49,53 @@ GEM
   specs:
     aasm (5.0.0)
       concurrent-ruby (~> 1.0)
-    actioncable (5.2.4.6)
-      actionpack (= 5.2.4.6)
+    actioncable (6.0.4)
+      actionpack (= 6.0.4)
       nio4r (~> 2.0)
       websocket-driver (>= 0.6.1)
-    actionmailer (5.2.4.6)
-      actionpack (= 5.2.4.6)
-      actionview (= 5.2.4.6)
-      activejob (= 5.2.4.6)
+    actionmailbox (6.0.4)
+      actionpack (= 6.0.4)
+      activejob (= 6.0.4)
+      activerecord (= 6.0.4)
+      activestorage (= 6.0.4)
+      activesupport (= 6.0.4)
+      mail (>= 2.7.1)
+    actionmailer (6.0.4)
+      actionpack (= 6.0.4)
+      actionview (= 6.0.4)
+      activejob (= 6.0.4)
       mail (~> 2.5, >= 2.5.4)
       rails-dom-testing (~> 2.0)
-    actionpack (5.2.4.6)
-      actionview (= 5.2.4.6)
-      activesupport (= 5.2.4.6)
+    actionpack (6.0.4)
+      actionview (= 6.0.4)
+      activesupport (= 6.0.4)
       rack (~> 2.0, >= 2.0.8)
       rack-test (>= 0.6.3)
       rails-dom-testing (~> 2.0)
-      rails-html-sanitizer (~> 1.0, >= 1.0.2)
-    actionview (5.2.4.6)
-      activesupport (= 5.2.4.6)
+      rails-html-sanitizer (~> 1.0, >= 1.2.0)
+    actiontext (6.0.4)
+      actionpack (= 6.0.4)
+      activerecord (= 6.0.4)
+      activestorage (= 6.0.4)
+      activesupport (= 6.0.4)
+      nokogiri (>= 1.8.5)
+    actionview (6.0.4)
+      activesupport (= 6.0.4)
       builder (~> 3.1)
       erubi (~> 1.4)
       rails-dom-testing (~> 2.0)
-      rails-html-sanitizer (~> 1.0, >= 1.0.3)
-    activejob (5.2.4.6)
-      activesupport (= 5.2.4.6)
+      rails-html-sanitizer (~> 1.1, >= 1.2.0)
+    activejob (6.0.4)
+      activesupport (= 6.0.4)
       globalid (>= 0.3.6)
-    activemodel (5.2.4.6)
-      activesupport (= 5.2.4.6)
-    activerecord (5.2.4.6)
-      activemodel (= 5.2.4.6)
-      activesupport (= 5.2.4.6)
-      arel (>= 9.0)
-    activerecord-import (1.0.2)
+    activemodel (6.0.4)
+      activesupport (= 6.0.4)
+    activerecord (6.0.4)
+      activemodel (= 6.0.4)
+      activesupport (= 6.0.4)
+    activerecord-import (1.0.5)
       activerecord (>= 3.2)
-    activerecord-nulldb-adapter (0.3.9)
+    activerecord-nulldb-adapter (0.4.0)
       activerecord (>= 2.0.0)
     activerecord-session_store (2.0.0)
       actionpack (>= 5.2.4.1)
@@ -91,20 +103,21 @@ GEM
       multi_json (~> 1.11, >= 1.11.2)
       rack (>= 2.0.8, < 3)
       railties (>= 5.2.4.1)
-    activestorage (5.2.4.6)
-      actionpack (= 5.2.4.6)
-      activerecord (= 5.2.4.6)
-      marcel (~> 0.3.1)
-    activesupport (5.2.4.6)
+    activestorage (6.0.4)
+      actionpack (= 6.0.4)
+      activejob (= 6.0.4)
+      activerecord (= 6.0.4)
+      marcel (~> 1.0.0)
+    activesupport (6.0.4)
       concurrent-ruby (~> 1.0, >= 1.0.2)
       i18n (>= 0.7, < 2)
       minitest (~> 5.1)
       tzinfo (~> 1.1)
-    acts_as_list (0.9.19)
-      activerecord (>= 3.0)
+      zeitwerk (~> 2.2, >= 2.2.2)
+    acts_as_list (1.0.1)
+      activerecord (>= 4.2)
     addressable (2.5.2)
       public_suffix (>= 2.0.2, < 4.0)
-    arel (9.0.0)
     argon2 (2.0.2)
       ffi (~> 1.9)
       ffi-compiler (>= 0.1)
@@ -137,9 +150,9 @@ GEM
     clearbit (0.2.8)
       nestful (~> 1.1.0)
     coderay (1.1.2)
-    coffee-rails (4.2.2)
+    coffee-rails (5.0.0)
       coffee-script (>= 2.2.0)
-      railties (>= 4.0.0)
+      railties (>= 5.2.0)
     coffee-script (2.4.1)
       coffee-script-source
       execjs
@@ -148,9 +161,9 @@ GEM
       coffee-script
       execjs
       json
-    composite_primary_keys (11.2.0)
-      activerecord (~> 5.2.1)
-    concurrent-ruby (1.1.8)
+    composite_primary_keys (12.0.2)
+      activerecord (~> 6.0.0)
+    concurrent-ruby (1.1.9)
     coveralls (0.8.23)
       json (>= 1.8, < 3)
       simplecov (~> 0.16.1)
@@ -163,10 +176,10 @@ GEM
     daemons (1.3.1)
     dalli (2.7.10)
     debug_inspector (0.0.3)
-    delayed_job (4.1.7)
-      activesupport (>= 3.0, < 5.3)
-    delayed_job_active_record (4.1.3)
-      activerecord (>= 3.0, < 5.3)
+    delayed_job (4.1.8)
+      activesupport (>= 3.0, < 6.1)
+    delayed_job_active_record (4.1.4)
+      activerecord (>= 3.0, < 6.1)
       delayed_job (>= 3.0, < 5)
     deprecation_toolkit (1.4.0)
       activesupport (>= 4.2)
@@ -275,23 +288,19 @@ GEM
     logging (2.2.2)
       little-plugger (~> 1.1)
       multi_json (~> 1.10)
-    loofah (2.9.1)
+    loofah (2.10.0)
       crass (~> 1.0.2)
       nokogiri (>= 1.5.9)
     lumberjack (1.0.13)
-    marcel (0.3.3)
-      mimemagic (~> 0.3.2)
+    marcel (1.0.1)
     memoizable (0.4.2)
       thread_safe (~> 0.3, >= 0.3.1)
     method_source (0.9.2)
     mime-types (3.2.2)
       mime-types-data (~> 3.2015)
     mime-types-data (3.2019.0331)
-    mimemagic (0.3.10)
-      nokogiri (~> 1)
-      rake
     mini_mime (1.1.0)
-    mini_portile2 (2.5.1)
+    mini_portile2 (2.5.3)
     mini_racer (0.2.9)
       libv8 (>= 6.9.411)
     minitest (5.14.4)
@@ -306,7 +315,7 @@ GEM
     net-ldap (0.16.1)
     netrc (0.11.0)
     nio4r (2.5.7)
-    nokogiri (1.11.5)
+    nokogiri (1.11.7)
       mini_portile2 (~> 2.5.0)
       racc (~> 1.4)
     nori (2.6.0)
@@ -396,18 +405,20 @@ GEM
       rack
     rack-test (1.1.0)
       rack (>= 1.0, < 3)
-    rails (5.2.4.6)
-      actioncable (= 5.2.4.6)
-      actionmailer (= 5.2.4.6)
-      actionpack (= 5.2.4.6)
-      actionview (= 5.2.4.6)
-      activejob (= 5.2.4.6)
-      activemodel (= 5.2.4.6)
-      activerecord (= 5.2.4.6)
-      activestorage (= 5.2.4.6)
-      activesupport (= 5.2.4.6)
+    rails (6.0.4)
+      actioncable (= 6.0.4)
+      actionmailbox (= 6.0.4)
+      actionmailer (= 6.0.4)
+      actionpack (= 6.0.4)
+      actiontext (= 6.0.4)
+      actionview (= 6.0.4)
+      activejob (= 6.0.4)
+      activemodel (= 6.0.4)
+      activerecord (= 6.0.4)
+      activestorage (= 6.0.4)
+      activesupport (= 6.0.4)
       bundler (>= 1.3.0)
-      railties (= 5.2.4.6)
+      railties (= 6.0.4)
       sprockets-rails (>= 2.0.0)
     rails-controller-testing (1.0.4)
       actionpack (>= 5.0.1.x)
@@ -418,12 +429,12 @@ GEM
       nokogiri (>= 1.6)
     rails-html-sanitizer (1.3.0)
       loofah (~> 2.3)
-    railties (5.2.4.6)
-      actionpack (= 5.2.4.6)
-      activesupport (= 5.2.4.6)
+    railties (6.0.4)
+      actionpack (= 6.0.4)
+      activesupport (= 6.0.4)
       method_source
       rake (>= 0.8.7)
-      thor (>= 0.19.0, < 2.0)
+      thor (>= 0.20.3, < 2.0)
     rainbow (3.0.0)
     raindrops (0.19.0)
     rake (12.3.3)
@@ -562,12 +573,13 @@ GEM
       addressable (>= 2.3.6)
       crack (>= 0.3.2)
       hashdiff
-    websocket-driver (0.7.3)
+    websocket-driver (0.7.5)
       websocket-extensions (>= 0.1.0)
     websocket-extensions (0.1.5)
     writeexcel (1.0.5)
     xpath (3.2.0)
       nokogiri (~> 1.8)
+    zeitwerk (2.4.2)
     zendesk_api (1.19.0)
       faraday (~> 0.9)
       hashie (>= 3.5.2, < 4.0.0)
@@ -650,7 +662,7 @@ DEPENDENCIES
   pundit
   pundit-matchers
   rack-livereload
-  rails (= 5.2.4.6)
+  rails (= 6.0.4)
   rails-controller-testing
   rb-fsevent
   rchardet (>= 1.8.0)

+ 0 - 1
app/controllers/channels_sms_controller.rb

@@ -98,7 +98,6 @@ class ChannelsSmsController < ApplicationController
     list = []
     Dir.glob(Rails.root.join('app/models/channel/driver/sms/*.rb')).each do |path|
       filename = File.basename(path)
-      require_dependency "channel/driver/sms/#{filename.sub('.rb', '')}"
       list.push Channel.driver_class("sms/#{filename}").definition
     end
     list

+ 0 - 2
app/controllers/channels_twitter_controller.rb

@@ -1,7 +1,5 @@
 # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
 
-require_dependency 'channel/driver/twitter'
-
 class ChannelsTwitterController < ApplicationController
   prepend_before_action -> { authentication_check && authorize! }, except: %i[webhook_incoming webhook_verify]
   skip_before_action :verify_csrf_token, only: %i[webhook_incoming webhook_verify]

+ 0 - 4
app/controllers/integration/ldap_controller.rb

@@ -1,9 +1,5 @@
 # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
 
-require_dependency 'ldap'
-require_dependency 'ldap/user'
-require_dependency 'ldap/group'
-
 class Integration::LdapController < ApplicationController
   include Integration::ImportJobBase
 

+ 0 - 1
app/controllers/search_controller.rb

@@ -65,7 +65,6 @@ class SearchController < ApplicationController
       if objects_with_direct_search_index.present?
         items = SearchIndexBackend.search(query, objects_with_direct_search_index, limit: limit)
         items.each do |item|
-          require_dependency item[:type].to_filename
           local_class = item[:type].constantize
           record = local_class.lookup(id: item[:id])
           next if !record

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