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

This changes the minimum supported version of PostgreSQL to 9.3.
This commit is contained in:
Thorsten Eckel 2021-06-23 11:35:27 +00:00 committed by Martin Gruner
parent 341bdd6eb9
commit ca56de3648
151 changed files with 409 additions and 458 deletions

View file

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

View file

@ -21,6 +21,17 @@ shellcheck:
script: script:
- shellcheck -S warning $(find . -name "*.sh" -o -name "functions" | grep -v "/vendor/") - 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: coffeelint:
<<: *template_pre <<: *template_pre
script: script:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # 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 class Integration::LdapController < ApplicationController
include Integration::ImportJobBase include Integration::ImportJobBase

View file

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

View file

@ -5,6 +5,8 @@ class ApplicationJob < ActiveJob::Base
include ApplicationJob::HasQueuingPriority include ApplicationJob::HasQueuingPriority
include ApplicationJob::HasCustomLogging include ApplicationJob::HasCustomLogging
ActiveJob::Logging::LogSubscriber.detach_from :active_job
# Automatically retry jobs that encountered a deadlock # Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked # retry_on ActiveRecord::Deadlocked

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'ldap'
require_dependency 'ldap/user'
class MigrateLdapSamaccountnameToUidJob < ApplicationJob class MigrateLdapSamaccountnameToUidJob < ApplicationJob
def perform def perform

View file

@ -158,7 +158,6 @@ get assets of object list
def assets_of_object_list(list, assets = {}) def assets_of_object_list(list, assets = {})
list.each do |item| list.each do |item|
require_dependency item['object'].to_filename
record = item['object'].constantize.lookup(id: item['o_id']) record = item['object'].constantize.lookup(id: item['o_id'])
next if record.blank? next if record.blank?

View file

@ -25,7 +25,7 @@ returns
return updated_at if updated_at return updated_at if updated_at
# if we do not have it cached, do lookup # if we do not have it cached, do lookup
updated_at = order(updated_at: :desc).limit(1).pluck(:updated_at).first updated_at = order(updated_at: :desc).limit(1).pick(:updated_at)
return if !updated_at return if !updated_at

View file

@ -6,7 +6,7 @@ class Authorization < ApplicationModel
after_update :delete_user_cache after_update :delete_user_cache
after_destroy :delete_user_cache after_destroy :delete_user_cache
validates :user_id, presence: true validates :user_id, presence: true
validates :uid, presence: true, uniqueness: { scope: :provider } validates :uid, presence: true, uniqueness: { case_sensitive: true, scope: :provider }
validates :provider, presence: true validates :provider, presence: true
def self.find_from_hash(hash) def self.find_from_hash(hash)

View file

@ -315,12 +315,6 @@ load channel driver and return class
=end =end
def self.driver_class(adapter) def self.driver_class(adapter)
# we need to require each channel backend individually otherwise we get a
# 'warning: toplevel constant Twitter referenced by Channel::Driver::Twitter' error e.g.
# so we have to convert the channel name to the filename via Rails String.underscore
# http://stem.ps/rails/2015/01/25/ruby-gotcha-toplevel-constant-referenced-by.html
require_dependency "channel/driver/#{adapter.to_filename}"
"::Channel::Driver::#{adapter.to_classname}".constantize "::Channel::Driver::#{adapter.to_classname}".constantize
end end

View file

@ -21,7 +21,7 @@ class Channel::Driver::Sms::Twilio
body: attr[:message], body: attr[:message],
) )
raise result.error_message if result.error_code.positive? raise result.error_message if result&.error_code&.positive?
end end
true true

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'external_credential/twitter'
class Channel::Driver::Twitter class Channel::Driver::Twitter
=begin =begin

View file

@ -159,7 +159,7 @@ module HasGroups
# @return [Hash<String=>String,Array<String>>] The given map # @return [Hash<String=>String,Array<String>>] The given map
def group_names_access_map=(name_access_map) def group_names_access_map=(name_access_map)
groups_access_map_store(name_access_map) do |group_name| groups_access_map_store(name_access_map) do |group_name|
Group.where(name: group_name).pluck(:id).first Group.where(name: group_name).pick(:id)
end end
end end

View file

@ -10,7 +10,7 @@ module HasTicketCreateScreenImpact
def push_ticket_create_screen? def push_ticket_create_screen?
return true if destroyed? return true if destroyed?
%w[id name active].any? do |attribute| %w[id name active updated_at].any? do |attribute|
saved_change_to_attribute?(attribute) saved_change_to_attribute?(attribute)
end end
end end

View file

@ -72,6 +72,7 @@ class DataPrivacyTask::Validation < ActiveModel::Validator
deletable: deletable deletable: deletable
).where.not( ).where.not(
id: record.id, id: record.id,
).where.not(
state: 'failed' state: 'failed'
).exists? ).exists?
end end

View file

@ -35,9 +35,7 @@ class ExternalCredential < ApplicationModel
end end
def self.load_backend(provider) def self.load_backend(provider)
adapter = "ExternalCredential::#{provider.camelcase}" "ExternalCredential::#{provider.camelcase}".constantize
require_dependency adapter.to_filename.to_s
adapter.constantize
end end
end end

View file

@ -20,7 +20,7 @@ class KnowledgeBase::Answer::Translation < ApplicationModel
validates :title, presence: true, length: { maximum: 250 } validates :title, presence: true, length: { maximum: 250 }
validates :content, presence: true validates :content, presence: true
validates :kb_locale_id, uniqueness: { scope: :answer_id } validates :kb_locale_id, uniqueness: { case_sensitive: true, scope: :answer_id }
scope :neighbours_of, ->(translation) { joins(:answer).where(knowledge_base_answers: { category_id: translation.answer&.category_id }) } scope :neighbours_of, ->(translation) { joins(:answer).where(knowledge_base_answers: { category_id: translation.answer&.category_id }) }

View file

@ -15,7 +15,7 @@ class KnowledgeBase::Category::Translation < ApplicationModel
validates :category, presence: true validates :category, presence: true
validates :title, presence: true validates :title, presence: true
validates :kb_locale_id, uniqueness: { scope: :category_id } validates :kb_locale_id, uniqueness: { case_sensitive: true, scope: :category_id }
scope :neighbours_of, ->(translation) { joins(:category).where(knowledge_base_categories: { parent_id: translation.category&.parent_id }) } scope :neighbours_of, ->(translation) { joins(:category).where(knowledge_base_categories: { parent_id: translation.category&.parent_id }) }

View file

@ -4,8 +4,8 @@ class KnowledgeBase::Locale < ApplicationModel
belongs_to :knowledge_base, inverse_of: :kb_locales, touch: true belongs_to :knowledge_base, inverse_of: :kb_locales, touch: true
belongs_to :system_locale, inverse_of: :knowledge_base_locales, class_name: '::Locale' belongs_to :system_locale, inverse_of: :knowledge_base_locales, class_name: '::Locale'
validates :primary, uniqueness: { scope: %i[system_locale_id knowledge_base_id] }, if: :primary? validates :primary, uniqueness: { case_sensitive: true, scope: %i[system_locale_id knowledge_base_id] }, if: :primary?
validates :system_locale_id, uniqueness: { scope: :knowledge_base_id } validates :system_locale_id, uniqueness: { case_sensitive: true, scope: :knowledge_base_id }
has_many :knowledge_base_translations, class_name: 'KnowledgeBase::Translation', has_many :knowledge_base_translations, class_name: 'KnowledgeBase::Translation',
inverse_of: :kb_locale, inverse_of: :kb_locale,

View file

@ -11,7 +11,7 @@ class KnowledgeBase::Translation < ApplicationModel
belongs_to :kb_locale, inverse_of: :knowledge_base_translations, class_name: 'KnowledgeBase::Locale' belongs_to :kb_locale, inverse_of: :knowledge_base_translations, class_name: 'KnowledgeBase::Locale'
validates :title, presence: true, length: { maximum: 250 } validates :title, presence: true, length: { maximum: 250 }
validates :kb_locale_id, uniqueness: { scope: :knowledge_base_id } validates :kb_locale_id, uniqueness: { case_sensitive: true, scope: :knowledge_base_id }
def assets(data) def assets(data)
return data if assets_added_to?(data) return data if assets_added_to?(data)

View file

@ -51,7 +51,8 @@ class ObjectManager::Attribute::Validation < ActiveModel::Validator
def sanitize_memory_cache def sanitize_memory_cache
@model_attributes = nil @model_attributes = nil
latest_cache_key = active_attributes_in_db.cache_key active_attributes = active_attributes_in_db
latest_cache_key = active_attributes.cache_key + active_attributes.cache_version
return if @previous_cache_key == latest_cache_key return if @previous_cache_key == latest_cache_key
@previous_cache_key = latest_cache_key @previous_cache_key = latest_cache_key

View file

@ -116,7 +116,7 @@ returns
def self.with_permissions(keys) def self.with_permissions(keys)
permission_ids = Role.permission_ids_by_name(keys) permission_ids = Role.permission_ids_by_name(keys)
Role.joins(:roles_permissions).joins(:permissions).where( Role.joins(:permissions_roles).joins(:permissions).where(
'permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true 'permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true
).distinct() ).distinct()
end end
@ -140,7 +140,7 @@ returns
def with_permission?(keys) def with_permission?(keys)
permission_ids = Role.permission_ids_by_name(keys) permission_ids = Role.permission_ids_by_name(keys)
return true if Role.joins(:roles_permissions).joins(:permissions).where( return true if Role.joins(:permissions_roles).joins(:permissions).where(
'roles.id = ? AND permissions_roles.permission_id IN (?) AND permissions.active = ?', id, permission_ids, true 'roles.id = ? AND permissions_roles.permission_id IN (?) AND permissions.active = ?', id, permission_ids, true
).distinct().count.nonzero? ).distinct().count.nonzero?

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
class SMIMECertificate < ApplicationModel class SMIMECertificate < ApplicationModel
validates :fingerprint, uniqueness: true validates :fingerprint, uniqueness: { case_sensitive: true }
def self.parse(raw) def self.parse(raw)
OpenSSL::X509::Certificate.new(raw.gsub(%r{(?:TRUSTED\s)?(CERTIFICATE---)}, '\1')) OpenSSL::X509::Certificate.new(raw.gsub(%r{(?:TRUSTED\s)?(CERTIFICATE---)}, '\1'))

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'store/object'
require_dependency 'store/file'
class Store < ApplicationModel class Store < ApplicationModel
PREFERENCES_SIZE_MAX = 2400 PREFERENCES_SIZE_MAX = 2400

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'stats/ticket_reopen'
# Adds new and updated tickets to the reopen log processing. # Adds new and updated tickets to the reopen log processing.
module Ticket::CallsStatsTicketReopenLog module Ticket::CallsStatsTicketReopenLog
extend ActiveSupport::Concern extend ActiveSupport::Concern

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'escalation'
module Ticket::Escalation module Ticket::Escalation
extend ActiveSupport::Concern extend ActiveSupport::Concern

View file

@ -244,7 +244,7 @@ or
return timestamp.to_s return timestamp.to_s
end end
record = Translation.where(locale: locale, source: 'timestamp', format: 'time').pluck(:target).first record = Translation.where(locale: locale, source: 'timestamp', format: 'time').pick(:target)
return timestamp.to_s if !record return timestamp.to_s if !record
record.sub!('dd', format('%<day>02d', day: timestamp.day)) record.sub!('dd', format('%<day>02d', day: timestamp.day))
@ -286,7 +286,7 @@ or
return date.to_s if date.class != Date return date.to_s if date.class != Date
record = Translation.where(locale: locale, source: 'date', format: 'time').pluck(:target).first record = Translation.where(locale: locale, source: 'date', format: 'time').pick(:target)
return date.to_s if !record return date.to_s if !record
record.sub!('dd', format('%<day>02d', day: date.day)) record.sub!('dd', format('%<day>02d', day: date.day))

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'karma/user'
class User < ApplicationModel class User < ApplicationModel
include CanBeAuthorized include CanBeAuthorized
include CanBeImported include CanBeImported
@ -14,7 +12,7 @@ class User < ApplicationModel
include HasGroups include HasGroups
include HasRoles include HasRoles
include HasObjectManagerAttributesValidation include HasObjectManagerAttributesValidation
include HasTicketCreateScreenImpact include ::HasTicketCreateScreenImpact
include HasTaskbars include HasTaskbars
include User::HasTicketCreateScreenImpact include User::HasTicketCreateScreenImpact
include User::Assets include User::Assets
@ -461,7 +459,7 @@ returns
end end
next if permission_ids.blank? next if permission_ids.blank?
Role.joins(:roles_permissions).joins(:permissions).where('permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true).distinct().pluck(:id).each do |role_id| Role.joins(:permissions_roles).joins(:permissions).where('permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true).distinct().pluck(:id).each do |role_id|
role_ids.push role_id role_ids.push role_id
end end
total_role_ids.push role_ids total_role_ids.push role_ids
@ -475,7 +473,7 @@ returns
end end
condition += 'roles_users.role_id IN (?)' condition += 'roles_users.role_id IN (?)'
end end
User.joins(:users_roles).where("(#{condition}) AND users.active = ?", *total_role_ids, true).distinct.order(:id) User.joins(:roles_users).where("(#{condition}) AND users.active = ?", *total_role_ids, true).distinct.order(:id)
end end
=begin =begin
@ -686,11 +684,11 @@ returns
def self.of_role(role, group_ids = nil) def self.of_role(role, group_ids = nil)
roles_ids = Role.where(active: true, name: role).map(&:id) roles_ids = Role.where(active: true, name: role).map(&:id)
if !group_ids if !group_ids
return User.where(active: true).joins(:users_roles).where('roles_users.role_id' => roles_ids).order('users.updated_at DESC') return User.where(active: true).joins(:roles_users).where('roles_users.role_id' => roles_ids).order('users.updated_at DESC')
end end
User.where(active: true) User.where(active: true)
.joins(:users_roles) .joins(:roles_users)
.joins(:users_groups) .joins(:users_groups)
.where('roles_users.role_id IN (?) AND users_groups.group_ids IN (?)', roles_ids, group_ids).order('users.updated_at DESC') .where('roles_users.role_id IN (?) AND users_groups.group_ids IN (?)', roles_ids, group_ids).order('users.updated_at DESC')
end end

View file

@ -1,16 +1,14 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
class User module User::HasTicketCreateScreenImpact
module HasTicketCreateScreenImpact extend ActiveSupport::Concern
extend ActiveSupport::Concern
def push_ticket_create_screen? def push_ticket_create_screen?
return true if destroyed? return true if destroyed?
return false if %w[id login firstname lastname preferences active].none? do |attribute| return false if %w[id login firstname lastname preferences active].none? do |attribute|
saved_change_to_attribute?(attribute) saved_change_to_attribute?(attribute)
end
permissions?('ticket.agent')
end end
permissions?('ticket.agent')
end end
end end

View file

@ -2,7 +2,6 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'fileutils' require 'fileutils'
include FileUtils # rubocop:disable Style/MixinUsage
# path to your application root. # path to your application root.
APP_ROOT = File.expand_path('..', __dir__) APP_ROOT = File.expand_path('..', __dir__)
@ -11,24 +10,25 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
end end
chdir APP_ROOT do FileUtils.chdir APP_ROOT do
# This script is a starting point to setup your application. # 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. # Add necessary setup steps to this file.
puts '== Installing dependencies ==' puts '== Installing dependencies =='
system! 'gem install bundler --conservative' system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install') system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn # Install JavaScript dependencies
# system('bin/yarn') # system('bin/yarn')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml' # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end # end
puts "\n== Preparing database ==" puts "\n== Preparing database =="
system! 'bin/rails db:setup' system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear' system! 'bin/rails log:clear tmp:clear'

View file

@ -3,9 +3,11 @@
APP_ROOT = File.expand_path('..', __dir__) APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do Dir.chdir(APP_ROOT) do
exec 'yarnpkg', *ARGV begin
rescue Errno::ENOENT exec "yarnpkg", *ARGV
warn 'Yarn executable was not detected in the system.' rescue Errno::ENOENT
warn 'Download Yarn at https://yarnpkg.com/en/docs/install' $stderr.puts "Yarn executable was not detected in the system."
exit 1 $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end end

View file

@ -15,14 +15,27 @@ Bundler.require(*Rails.groups)
module Zammad module Zammad
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2 config.load_defaults 6.0
Rails.autoloaders.each do |autoloader|
autoloader.do_not_eager_load "#{config.root}/lib/core_ext"
autoloader.collapse "#{config.root}/lib/omniauth"
autoloader.inflector.inflect(
'github_database' => 'GithubDatabase',
'otrs' => 'OTRS',
'db' => 'DB',
)
end
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W[#{config.root}/lib] config.add_autoload_paths_to_load_path = false
config.autoload_paths += %W[#{config.root}/lib]
config.eager_load_paths += %W[#{config.root}/lib] config.eager_load_paths += %W[#{config.root}/lib]
config.active_job.queue_adapter = :delayed_job config.active_job.queue_adapter = :delayed_job
@ -36,6 +49,9 @@ module Zammad
# define cache store # define cache store
config.cache_store = :zammad_file_store, Rails.root.join('tmp', "cache_file_store_#{Rails.env}"), { expires_in: 7.days } config.cache_store = :zammad_file_store, Rails.root.join('tmp', "cache_file_store_#{Rails.env}"), { expires_in: 7.days }
# Rails 6.1 returns false when the enqueuing is aborted.
config.active_job.return_false_on_aborted_enqueue = true
# default preferences by permission # default preferences by permission
config.preferences_default_by_permission = { config.preferences_default_by_permission = {
'ticket.agent' => { 'ticket.agent' => {

10
config/cable.yml Normal file
View file

@ -0,0 +1,10 @@
development:
adapter: async
test:
adapter: test
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: zammad_production

View file

@ -18,6 +18,7 @@ Rails.application.configure do
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
if Rails.root.join('tmp/caching-dev.txt').exist? if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# config.action_controller.enable_fragment_cache_logging = true
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}" 'Cache-Control' => "public, max-age=#{2.days.to_i}"
@ -26,7 +27,7 @@ Rails.application.configure do
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
end end
# Store uploaded files on the local file system (see config/storage.yml for options) # Store uploaded files on the local file system (see config/storage.yml for options).
# config.active_storage.service = :local # config.active_storage.service = :local
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
@ -51,7 +52,7 @@ Rails.application.configure do
# Suppress logger output for asset requests. # Suppress logger output for asset requests.
config.assets.quiet = true config.assets.quiet = true
# Raises error for missing translations # Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
@ -69,4 +70,8 @@ Rails.application.configure do
# Raises error for missing translations # Raises error for missing translations
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# TODO: New in Rails 6
# See https://www.fngtps.com/2019/rails6-blocked-host/
config.hosts.clear
end end

View file

@ -40,10 +40,10 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options) # Store uploaded files on the local file system (see config/storage.yml for options).
# config.active_storage.service = :local # config.active_storage.service = :local
# Mount Action Cable outside main process or domain # Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil # config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable' # config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
@ -61,7 +61,7 @@ Rails.application.configure do
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # 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_adapter = :resque
# config.active_job.queue_name_prefix = "zammad_#{Rails.env}" # config.active_job.queue_name_prefix = "zammad_#{Rails.env}"

View file

@ -30,7 +30,7 @@ Rails.application.configure do
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory # Store uploaded files on the local file system in a temporary directory.
# config.active_storage.service = :test # config.active_storage.service = :test
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
@ -46,7 +46,7 @@ Rails.application.configure do
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
# Raises error for missing translations # Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# Enable autoload # Enable autoload

View file

@ -13,6 +13,8 @@
# policy.object_src :none # policy.object_src :none
# policy.script_src :self, :https # policy.script_src :self, :https
# policy.style_src :self, :https # policy.style_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
# # Specify URI for violation reports # # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint" # # policy.report_uri "/csp-violation-report-endpoint"
@ -43,6 +45,9 @@ end
# If you are using UJS then enable automatic nonce generation # If you are using UJS then enable automatic nonce generation
Rails.application.config.content_security_policy_nonce_generator = ->(_request) { SecureRandom.base64(16) } 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 # Report CSP violations to a specified URI
# For further information see the following documentation: # For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only

View file

@ -3,4 +3,4 @@
# Rails' constant auto-loading resolves to 'rails/initializable' instead # Rails' constant auto-loading resolves to 'rails/initializable' instead
require_dependency 'zammad/application/initializer/db_preflight_check' require_dependency 'zammad/application/initializer/db_preflight_check'
Zammad::Application::Initializer::DBPreflightCheck.perform Zammad::Application::Initializer::DbPreflightCheck.perform

View file

@ -0,0 +1,47 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# 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

View file

@ -1,20 +0,0 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# This is a workaround because `ActiveSupport::Subscriber` supports only `attach_to` but not `detach_from` in Rails 5.2.
# `detach_from` was added with Rails 6.0: https://github.com/rails/rails/commit/ca19b7f5d86aa590077766cbe8006f952b6d4296
# Once Rails 6.0 is used `ActiveJob::Logging::LogSubscriber.detach_from :active_job` needs to be added to `app/jobs/application_job.rb` instead.
ActiveSupport.on_load(:active_job) do
# gather all `ActiveJob::Logging::LogSubscriber` event subscribers
subscribers = ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).select do |subscriber|
subscriber.instance_variable_get(:@delegate).instance_of?(ActiveJob::Logging::LogSubscriber)
end
# remove gathered event subscribers in a dedicated step to not work on iterating array
subscribers.each do |subscriber|
ActiveSupport::Notifications.notifier.unsubscribe(subscriber)
end
# remove whole `ActiveJob::Logging::LogSubscriber` subscriber reference
ActiveSupport::Subscriber.subscribers.delete_if { |subscriber| subscriber.instance_of?(ActiveJob::Logging::LogSubscriber) }
end

View file

@ -27,7 +27,7 @@
# 'true': 'foo' # 'true': 'foo'
# #
# To learn more, please read the Rails Internationalization guide # To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html. # available at https://guides.rubyonrails.org/i18n.html.
en: en:
hello: "Hello world" hello: "Hello world"

View file

@ -2,13 +2,15 @@
Rails.application.routes.draw do Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
# app init # app init
match '/init', to: 'init#index', via: :get match '/init', to: 'init#index', via: :get
match '/app', to: 'init#index', via: :get match '/app', to: 'init#index', via: :get
# just remember to delete public/index.html. # just remember to delete public/index.html.
root to: 'init#index', via: :get root to: 'init#index', via: :get
root to: 'errors#routing', via: %i[post put delete options] root to: 'errors#routing', via: %i[post put delete options], as: nil
# load routes from external files # load routes from external files
dir = File.expand_path(__dir__) dir = File.expand_path(__dir__)

View file

@ -1,11 +1,11 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
%w[ Spring.watch(
.ruby-version '.ruby-version',
.rbenv-vars '.rbenv-vars',
tmp/restart.txt 'tmp/restart.txt',
tmp/caching-dev.txt 'tmp/caching-dev.txt',
].each { |path| Spring.watch(path) } )
module Spring module Spring
module Commands module Commands

34
config/storage.yml Normal file
View file

@ -0,0 +1,34 @@
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]

View file

@ -0,0 +1,12 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# This migration comes from active_storage (originally 20180723000244)
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
def up
return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
return if !table_exists?(:active_storage_blobs)
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
end
end

View file

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'assets_set/proxy'
# The name AssetsSet combines the Assets term in Zammad with the Set class from the Ruby StdLib. # The name AssetsSet combines the Assets term in Zammad with the Set class from the Ruby StdLib.
# Zammad Assets serve the purpose to limit requests to the REST API. For a requested object all # Zammad Assets serve the purpose to limit requests to the REST API. For a requested object all
# related and relevant objects are collected recursively and then send to the client in one go. # related and relevant objects are collected recursively and then send to the client in one go.

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'ldap'
require_dependency 'ldap/user'
class Auth class Auth
class Ldap < Auth::Base class Ldap < Auth::Base

View file

@ -18,7 +18,7 @@ module ActiveRecord
def pluck_as_hash(*column_names) def pluck_as_hash(*column_names)
column_names.flatten! # flatten args in case array was given column_names.flatten! # flatten args in case array was given
klass.enforce_raw_sql_whitelist(column_names) # keep up deprection as in #pluck to ensure smooth Rails 6 transition klass.disallow_raw_sql!(column_names) # validate parameters as in #pluck
pluck(*arel_columns(column_names)) pluck(*arel_columns(column_names))
.map { |elem| pluck_as_hash_map(column_names, elem) } .map { |elem| pluck_as_hash_map(column_names, elem) }

View file

@ -1,4 +1,3 @@
# rubocop:disable Naming/FileName
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
if Kernel.respond_to?(:open_uri_original_open) if Kernel.respond_to?(:open_uri_original_open)
@ -20,4 +19,3 @@ if Kernel.respond_to?(:open_uri_original_open)
end end
end end
end end
# rubocop:enable Naming/FileName

View file

@ -227,8 +227,6 @@ returns on fail
# connection test # connection test
result_inbound = {} result_inbound = {}
begin begin
require_dependency "channel/driver/#{adapter.to_filename}"
driver_class = "Channel::Driver::#{adapter.to_classname}".constantize driver_class = "Channel::Driver::#{adapter.to_classname}".constantize
driver_instance = driver_class.new driver_instance = driver_class.new
result_inbound = driver_instance.fetch(params[:options], nil, 'check') result_inbound = driver_instance.fetch(params[:options], nil, 'check')
@ -330,8 +328,6 @@ returns on fail
# test connection # test connection
begin begin
require_dependency "channel/driver/#{adapter.to_filename}"
driver_class = "Channel::Driver::#{adapter.to_classname}".constantize driver_class = "Channel::Driver::#{adapter.to_classname}".constantize
driver_instance = driver_class.new driver_instance = driver_class.new
driver_instance.send( driver_instance.send(

View file

@ -82,8 +82,6 @@ or
fetch_result = nil fetch_result = nil
begin begin
require_dependency "channel/driver/#{adapter.to_filename}"
driver_class = "Channel::Driver::#{adapter.to_classname}".constantize driver_class = "Channel::Driver::#{adapter.to_classname}".constantize
driver_instance = driver_class.new driver_instance = driver_class.new
fetch_result = driver_instance.fetch(params[:inbound][:options], self, 'verify', subject) fetch_result = driver_instance.fetch(params[:inbound][:options], self, 'verify', subject)

View file

@ -57,7 +57,9 @@ class ExcelSheet::Ticket < ExcelSheet
object_lookup: ObjectLookup.lookup(name: 'Ticket') object_lookup: ObjectLookup.lookup(name: 'Ticket')
) )
.where.not( .where.not(
name: header.pluck(:name), name: header.pluck(:name)
)
.where.not(
display: header.pluck(:display) display: header.pluck(:display)
) )
.pluck_as_hash(:name, :display, :data_type, :data_option) .pluck_as_hash(:name, :display, :data_type, :data_option)

View file

@ -1,13 +1,13 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# rubocop:disable Rails/Output # rubocop:disable Rails/Output
module FillDB module FillDb
=begin =begin
fill your database with demo records fill your database with demo records
FillDB.load( FillDb.load(
agents: 50, agents: 50,
customers: 1000, customers: 1000,
groups: 20, groups: 20,
@ -18,10 +18,10 @@ fill your database with demo records
or if you only want to create 100 tickets or if you only want to create 100 tickets
FillDB.load(tickets: 100) FillDb.load(tickets: 100)
FillDB.load(agents: 20) FillDb.load(agents: 20)
FillDB.load(overviews: 20) FillDb.load(overviews: 20)
FillDB.load(tickets: 10000) FillDb.load(tickets: 10000)
=end =end

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'mixin/rails_logger'
module Import module Import
class Exchange class Exchange
class Folder class Folder

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'ldap'
require_dependency 'ldap/group'
module Import module Import
class Ldap < Import::IntegrationBase class Ldap < Import::IntegrationBase
include Import::Mixin::Sequence include Import::Mixin::Sequence

View file

@ -1,28 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# Rails autoload has some issues with same namend sub-classes
# in the importer folder require AND simultaniuos requiring
# of the same file in different threads so we need to
# require them ourself
require_dependency 'import/otrs/ticket'
require_dependency 'import/otrs/ticket_factory'
require_dependency 'import/otrs/article_customer'
require_dependency 'import/otrs/article_customer_factory'
require_dependency 'import/otrs/article'
require_dependency 'import/otrs/article_factory'
require_dependency 'import/otrs/article/attachment_factory'
require_dependency 'import/otrs/history'
require_dependency 'import/otrs/history_factory'
require_dependency 'import/otrs/history/article'
require_dependency 'import/otrs/history/move'
require_dependency 'import/otrs/history/new_ticket'
require_dependency 'import/otrs/history/priority_update'
require_dependency 'import/otrs/history/state_update'
require_dependency 'store'
require_dependency 'store/object'
require_dependency 'store/provider/db'
require_dependency 'store/provider/file'
module Import module Import
module OTRS module OTRS
extend Import::Helper extend Import::Helper

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/otrs/dynamic_field'
module Import module Import
module OTRS module OTRS
class DynamicField class DynamicField

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/otrs/dynamic_field'
module Import module Import
module OTRS module OTRS
class DynamicField class DynamicField

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'ticket'
module Import module Import
module OTRS module OTRS
class Ticket class Ticket

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,10 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
# this require is required (hehe) because of Rails autoloading
# which causes strange behavior not inheriting correctly
# from Import::OTRS::DynamicField
require_dependency 'import/zendesk/object_attribute/base'
module Import module Import
class Zendesk class Zendesk
module ObjectAttribute module ObjectAttribute

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'net/ldap'
require_dependency 'net/ldap/entry'
# Class for establishing LDAP connections. A wrapper around Net::LDAP needed for Auth and Sync. # Class for establishing LDAP connections. A wrapper around Net::LDAP needed for Auth and Sync.
# ATTENTION: Loads custom 'net/ldap/entry' from 'lib/core_ext' which extends the Net::LDAP::Entry class. # ATTENTION: Loads custom 'net/ldap/entry' from 'lib/core_ext' which extends the Net::LDAP::Entry class.
# #

View file

@ -3,13 +3,6 @@
class Ldap class Ldap
# Class for handling LDAP Groups. # Class for handling LDAP Groups.
# ATTENTION: Make sure to add the following lines to your code if accessing this class.
# Otherwise Rails will autoload the Group model or might throw parameter errors if crearing
# an ::Ldap instance.
#
# @example
# require_dependency 'ldap'
# require_dependency 'ldap/group'
class Group class Group
include Ldap::FilterLookup include Ldap::FilterLookup
@ -31,8 +24,6 @@ class Ldap
# @param ldap [Ldap] An optional existing Ldap class instance. Default is a new connection with given configuration. # @param ldap [Ldap] An optional existing Ldap class instance. Default is a new connection with given configuration.
# #
# @example # @example
# require_dependency 'ldap'
# require_dependency 'ldap/group'
# ldap_group = Ldap::Group.new # ldap_group = Ldap::Group.new
# #
# @return [nil] # @return [nil]

View file

@ -3,13 +3,6 @@
class Ldap class Ldap
# Class for handling LDAP Groups. # Class for handling LDAP Groups.
# ATTENTION: Make sure to add the following lines to your code if accessing this class.
# Otherwise Rails will autoload the Group model or might throw parameter errors if crearing
# an ::Ldap instance.
#
# @example
# require_dependency 'ldap'
# require_dependency 'ldap/user'
class User class User
include Ldap::FilterLookup include Ldap::FilterLookup
@ -79,8 +72,6 @@ class Ldap
# @param ldap [Ldap] An optional existing Ldap class instance. Default is a new connection with given configuration. # @param ldap [Ldap] An optional existing Ldap class instance. Default is a new connection with given configuration.
# #
# @example # @example
# require_dependency 'ldap'
# require_dependency 'ldap/user'
# ldap_user = Ldap::User.new # ldap_user = Ldap::User.new
# #
# @return [nil] # @return [nil]

View file

@ -9,18 +9,10 @@ module Mixin
eager_load_recursive(sub_path) eager_load_recursive(sub_path)
end end
# Loads a directory recursively. # Loads a directory recursively. This can be needed when accessing
# The specialty of this method is that it will first load all # modules not directly via .constantize on a known string, but dynamically
# files in a directory and then start with the sub directories. # via the inheritance tree, e.g. via .descendants (which assumes they have
# This is needed since otherwise some parent namespaces might not # previously been loaded).
# be initialized yet.
#
# The cause of this is that Rails autoload doesn't work properly
# for same named classes or modules in different namespaces.
# Here is a good description how autoload works:
# http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/
#
# This avoids a) Rails autoloading issues and b) require '...' workarounds
def self.eager_load_recursive(path) def self.eager_load_recursive(path)
excluded = ['.', '..'] excluded = ['.', '..']

View file

@ -298,7 +298,7 @@ remove whole data from index
query_data = build_query(condition, options) query_data = build_query(condition, options)
if (fields = options.dig(:highlight_fields_by_indexes, index.to_sym)) if (fields = options.dig(:highlight_fields_by_indexes, index.to_sym))
fields_for_highlight = fields.each_with_object({}) { |elem, memo| memo[elem] = {} } fields_for_highlight = fields.index_with { |_elem| {} }
query_data[:highlight] = { fields: fields_for_highlight } query_data[:highlight] = { fields: fields_for_highlight }
end end

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'mixin/rails_logger'
require_dependency 'mixin/start_finish_logger'
class Sequencer class Sequencer
include ::Mixin::RailsLogger include ::Mixin::RailsLogger
include ::Mixin::StartFinishLogger include ::Mixin::StartFinishLogger

View file

@ -1,10 +1,7 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/mixin/prefixed_constantize'
class Sequencer class Sequencer
class Sequence class Sequence
include ::Mixin::RequiredSubPaths
extend ::Sequencer::Mixin::PrefixedConstantize extend ::Sequencer::Mixin::PrefixedConstantize
PREFIX = 'Sequencer::Sequence::'.freeze PREFIX = 'Sequencer::Sequence::'.freeze

View file

@ -9,14 +9,14 @@ class Sequencer
def self.sequence def self.sequence
[ [
'Import::Zendesk::Ticket::Skip::Deleted', 'Import::Zendesk::Ticket::Skip::Deleted',
'Import::Zendesk::Ticket::UserID', 'Import::Zendesk::Ticket::UserId',
'Import::Zendesk::Ticket::OwnerID', 'Import::Zendesk::Ticket::OwnerId',
'Import::Zendesk::Ticket::GroupID', 'Import::Zendesk::Ticket::GroupId',
'Import::Zendesk::Ticket::OrganizationID', 'Import::Zendesk::Ticket::OrganizationId',
'Import::Zendesk::Ticket::PriorityID', 'Import::Zendesk::Ticket::PriorityId',
'Import::Zendesk::Ticket::StateID', 'Import::Zendesk::Ticket::StateId',
'Import::Zendesk::Common::ArticleSenderID', 'Import::Zendesk::Common::ArticleSenderId',
'Import::Zendesk::Common::ArticleTypeID', 'Import::Zendesk::Common::ArticleTypeId',
'Import::Zendesk::Ticket::Subject', 'Import::Zendesk::Ticket::Subject',
'Import::Zendesk::Ticket::CustomFields', 'Import::Zendesk::Ticket::CustomFields',
'Import::Zendesk::Ticket::Mapping', 'Import::Zendesk::Ticket::Mapping',

View file

@ -9,9 +9,9 @@ class Sequencer
def self.sequence def self.sequence
[ [
'Import::Zendesk::Ticket::Comment::UserID', 'Import::Zendesk::Ticket::Comment::UserId',
'Import::Zendesk::Common::ArticleSenderID', 'Import::Zendesk::Common::ArticleSenderId',
'Import::Zendesk::Common::ArticleTypeID', 'Import::Zendesk::Common::ArticleTypeId',
'Import::Zendesk::Ticket::Comment::From', 'Import::Zendesk::Ticket::Comment::From',
'Import::Zendesk::Ticket::Comment::To', 'Import::Zendesk::Ticket::Comment::To',
'Import::Zendesk::Ticket::Comment::Mapping', 'Import::Zendesk::Ticket::Comment::Mapping',

View file

@ -14,7 +14,7 @@ class Sequencer
'Import::Zendesk::User::Login', 'Import::Zendesk::User::Login',
'Import::Zendesk::User::Password', 'Import::Zendesk::User::Password',
'Import::Zendesk::User::ImageSource', 'Import::Zendesk::User::ImageSource',
'Import::Zendesk::User::OrganizationID', 'Import::Zendesk::User::OrganizationId',
'Common::ModelClass::User', 'Common::ModelClass::User',
'Import::Zendesk::User::Mapping', 'Import::Zendesk::User::Mapping',
'Import::Zendesk::User::CustomFields', 'Import::Zendesk::User::CustomFields',

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'mixin/rails_logger'
require_dependency 'mixin/start_finish_logger'
class Sequencer class Sequencer
class State class State
include ::Mixin::RailsLogger include ::Mixin::RailsLogger
@ -166,7 +163,7 @@ class Sequencer
# #
# @return [Hash{Symbol => Object}] # @return [Hash{Symbol => Object}]
def to_h def to_h
available.map { |identifier| [identifier, @values[identifier]] }.to_h available.index_with { |identifier| @values[identifier] }
end end
private private

View file

@ -1,10 +1,7 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/mixin/prefixed_constantize'
class Sequencer class Sequencer
class Unit class Unit
include ::Mixin::RequiredSubPaths
extend ::Sequencer::Mixin::PrefixedConstantize extend ::Sequencer::Mixin::PrefixedConstantize
PREFIX = 'Sequencer::Unit::'.freeze PREFIX = 'Sequencer::Unit::'.freeze

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'mixin/rails_logger'
class Sequencer class Sequencer
class Unit class Unit
class Base class Base

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/mixin/handle_failure'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/mixin/handle_failure'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/common/mixin/dynamic_attribute'
require_dependency 'sequencer/unit/import/common/model/mixin/log/context_identification_string'
# This unit checks if an Sequencer state attribute (e.g. `mapped`) is blank. # This unit checks if an Sequencer state attribute (e.g. `mapped`) is blank.
# Don't confuse it with e.g. 'Import::Common::Model::Skip::MissingMandatory::Base' which checks if an attribute key (e.g. mapped[:some_key]) is blank/missing. # Don't confuse it with e.g. 'Import::Common::Model::Skip::MissingMandatory::Base' which checks if an attribute key (e.g. mapped[:some_key]) is blank/missing.
class Sequencer class Sequencer

View file

@ -1,8 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/common/mixin/dynamic_attribute'
require_dependency 'sequencer/unit/import/common/model/mixin/log/context_identification_string'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -1,6 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/action_diff'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/action_diff'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/common'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/common'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -19,7 +19,7 @@ class Sequencer
end end
def empty_diff def empty_diff
possible_actions.collect { |key| [key, 0] }.to_h possible_actions.index_with { |_key| 0 }
end end
def possible_actions def possible_actions

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/common'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -18,8 +18,8 @@ class Sequencer
def group_ids_access_map def group_ids_access_map
@group_ids_access_map ||= begin @group_ids_access_map ||= begin
::Group.all.pluck(:id).each_with_object({}) do |group_id, result| ::Group.all.pluck(:id).index_with do
result[group_id] = 'full'.freeze 'full'.freeze
end end
end end
end end

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/action_diff'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

View file

@ -5,7 +5,7 @@ class Sequencer
module Import module Import
module Ldap module Ldap
module Users module Users
class DryRun module DryRun
class Payload < Sequencer::Unit::Import::Common::ImportJob::Payload::ToAttribute class Payload < Sequencer::Unit::Import::Common::ImportJob::Payload::ToAttribute
provides :ldap_config provides :ldap_config
end end

View file

@ -1,7 +1,5 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require_dependency 'sequencer/unit/import/common/model/statistics/mixin/empty_diff'
class Sequencer class Sequencer
class Unit class Unit
module Import module Import

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