]> source.dussan.org Git - redmine.git/commitdiff
Use ApplicationRecord instead of ActiveRecord::Base (#38975).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 23 Jan 2024 11:52:38 +0000 (11:52 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 23 Jan 2024 11:52:38 +0000 (11:52 +0000)
Patch by Minoru Maeda (@maeda-m).

git-svn-id: https://svn.redmine.org/redmine/trunk@22619 e93f8b46-1217-0410-a6f0-8f06a7374b81

63 files changed:
.rubocop.yml
.rubocop_todo.yml
app/controllers/watchers_controller.rb
app/models/application_record.rb [new file with mode: 0644]
app/models/attachment.rb
app/models/auth_source.rb
app/models/board.rb
app/models/change.rb
app/models/changeset.rb
app/models/comment.rb
app/models/custom_field.rb
app/models/custom_field_enumeration.rb
app/models/custom_value.rb
app/models/document.rb
app/models/email_address.rb
app/models/enabled_module.rb
app/models/enumeration.rb
app/models/import.rb
app/models/import_item.rb
app/models/issue.rb
app/models/issue_category.rb
app/models/issue_relation.rb
app/models/issue_status.rb
app/models/journal.rb
app/models/journal_detail.rb
app/models/member.rb
app/models/member_role.rb
app/models/message.rb
app/models/news.rb
app/models/principal.rb
app/models/project.rb
app/models/query.rb
app/models/repository.rb
app/models/role.rb
app/models/setting.rb
app/models/time_entry.rb
app/models/token.rb
app/models/tracker.rb
app/models/user_preference.rb
app/models/version.rb
app/models/watcher.rb
app/models/wiki.rb
app/models/wiki_content.rb
app/models/wiki_content_version.rb
app/models/wiki_page.rb
app/models/wiki_redirect.rb
app/models/workflow_rule.rb
config/initializers/10-patches.rb
extra/sample_plugin/app/models/meeting.rb
lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb
lib/plugins/acts_as_activity_provider/init.rb
lib/plugins/acts_as_attachable/init.rb
lib/plugins/acts_as_customizable/init.rb
lib/plugins/acts_as_event/init.rb
lib/plugins/acts_as_searchable/init.rb
lib/plugins/acts_as_tree/README
lib/plugins/acts_as_tree/init.rb
lib/plugins/acts_as_tree/lib/active_record/acts/tree.rb
lib/plugins/acts_as_tree/test/acts_as_tree_test.rb
lib/plugins/acts_as_watchable/init.rb
lib/plugins/gravatar/init.rb
lib/redmine/preparation.rb
test/unit/initializers/patches_test.rb

index 4fae950f00a87115a16fae7431c195164c8bb464..4dc78a91148e9421c0c5a24cce543eeb5fda7adb 100644 (file)
@@ -129,6 +129,10 @@ Rails/ActiveSupportOnLoad:
     # TODO: Need to check the impact on plugins. Disable for now.
     - 'lib/redmine/preparation.rb'
 
+Rails/ApplicationRecord:
+  Exclude:
+    - 'db/migrate/0*.rb'
+
 Rails/BulkChangeTable:
   Exclude:
     - 'db/migrate/20120714122200_add_workflows_rule_fields.rb'
index 93b0bbd211af39fd8509b130a96f7fcb456c4abb..1d45121c217400e2a396775d9a9bf56220875e27 100644 (file)
@@ -497,10 +497,6 @@ Rails/ApplicationMailer:
     - 'app/models/mail_handler.rb'
     - 'app/models/mailer.rb'
 
-# This cop supports unsafe autocorrection (--autocorrect-all).
-Rails/ApplicationRecord:
-  Enabled: false
-
 # This cop supports safe autocorrection (--autocorrect).
 # Configuration parameters: Include.
 # Include: **/test/**/*
index dbacb5c766bd841a21b30a4f0ac1264b99311fa4..ae7d09e95be7c13c2178696b67344e4ddd0d3bb4 100644 (file)
@@ -209,7 +209,7 @@ class WatchersController < ApplicationController
         nil
       end
     return unless klass && Class === klass # rubocop:disable Style/CaseEquality
-    return unless klass < ActiveRecord::Base
+    return unless klass < ApplicationRecord
     return unless klass < Redmine::Acts::Watchable::InstanceMethods
 
     scope = klass.where(:id => Array.wrap(params[:object_id]))
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644 (file)
index 0000000..3c89dc6
--- /dev/null
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+# Redmine - project management software
+# Copyright (C) 2006-2023  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+class ApplicationRecord < ActiveRecord::Base
+  self.abstract_class = true
+
+  # Translate attribute names for validation errors display
+  def self.human_attribute_name(attr, options = {})
+    prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
+    class_prefix = name.underscore.tr('/', '_')
+    redmine_default = [
+      :"field_#{class_prefix}_#{prepared_attr}",
+      :"field_#{prepared_attr}"
+    ]
+    options[:default] = redmine_default + Array(options[:default])
+    super
+  end
+end
index 97dea32bde567143d7a00260d4fa82103fa69da1..b168f07291769207e1a775b03c80c59a33b0ec93 100644 (file)
@@ -21,7 +21,7 @@ require "digest"
 require "fileutils"
 require "zip"
 
-class Attachment < ActiveRecord::Base
+class Attachment < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :container, :polymorphic => true
   belongs_to :author, :class_name => "User"
index c871e30c6df17851a5199245d3848c7a2922a247..9f444bb5a39117043ab3011e73932b06e55b469f 100644 (file)
@@ -22,7 +22,7 @@
 class AuthSourceException < StandardError; end
 class AuthSourceTimeoutException < AuthSourceException; end
 
-class AuthSource < ActiveRecord::Base
+class AuthSource < ApplicationRecord
   include Redmine::SafeAttributes
   include Redmine::SubclassFactory
   include Redmine::Ciphering
index 8cf16f559ade72db41611859e4355a3224406b84..e9cbf60eb70d4726ecec7d1959f26c3556653a4b 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Board < ActiveRecord::Base
+class Board < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :project
   has_many :messages, lambda {order("#{Message.table_name}.created_on DESC")}, :dependent => :destroy
index f2eff4ea1c7dfbeed56bb9097930f6d7ee77e557..62d41e2611976b0f3c6adeeab676870776d95a8d 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Change < ActiveRecord::Base
+class Change < ApplicationRecord
   belongs_to :changeset
 
   validates_presence_of :changeset_id, :action, :path
index 535335ef8d739dfe63d13712467d3e8a7b09ad55..833d09d45bef6c70d4928f6fee1bcb55c4cf7550 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Changeset < ActiveRecord::Base
+class Changeset < ApplicationRecord
   belongs_to :repository
   belongs_to :user
   has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
index 525a3a4ab3b364fd53fdcbdc9883c76004946907..71856035d622a78fb567cd20287e5f6a3628b2c9 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Comment < ActiveRecord::Base
+class Comment < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :commented, :polymorphic => true, :counter_cache => true
   belongs_to :author, :class_name => 'User'
index be9cf550f57b3f3f26ec1b864ec914e0c0639161..fa9d5ab73c9ae589bdf1a7c3f7fea4eb5d7d0e55 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class CustomField < ActiveRecord::Base
+class CustomField < ApplicationRecord
   include Redmine::SafeAttributes
   include Redmine::SubclassFactory
 
index 547d6a359c86bba83c747f0b2b7f8a78471fef57..81c5fbe79cc01e62ca9c7cef7009524ba1fad0ba 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class CustomFieldEnumeration < ActiveRecord::Base
+class CustomFieldEnumeration < ApplicationRecord
   belongs_to :custom_field
 
   validates_presence_of :name, :position, :custom_field_id
index 9cfac307979c997bd39d3f4b65e58877f5ae5080..b90a05549174f44445d407af283a6f0c981bbded 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class CustomValue < ActiveRecord::Base
+class CustomValue < ApplicationRecord
   belongs_to :custom_field
   belongs_to :customized, :polymorphic => true
 
index 51cc8d837ae121b6fee23cdd91c9393bb12e75ec..c2fc75c666f7879282ee5111c5cf94cbfa3ea634 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Document < ActiveRecord::Base
+class Document < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :project
   belongs_to :category, :class_name => "DocumentCategory"
index cc9064e0458fcbba248662d89068f311b41d7243..a62ac9cf9566e77c179d70b7363cea4d5d2bc60f 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class EmailAddress < ActiveRecord::Base
+class EmailAddress < ApplicationRecord
   include Redmine::SafeAttributes
 
   belongs_to :user
index 1b97903fb4f1592123ac128fa30fbe8593cf824b..17ca8a9f4f446ec6cea5655ea7cc33e064ee077d 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class EnabledModule < ActiveRecord::Base
+class EnabledModule < ApplicationRecord
   belongs_to :project
   acts_as_watchable
 
index f2f63372a8b26793ed4342335020915e0ef2f0f5..b61711644079c7ff9fe334faece4d7f33cfb2829 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Enumeration < ActiveRecord::Base
+class Enumeration < ApplicationRecord
   include Redmine::SubclassFactory
 
   default_scope lambda {order(:position)}
index 8fcb769d3f8e3b8bb83699b2bafe74b1d4408479..91cc8cb0f7b888028b9d5ffe97fffb4f333507c0 100644 (file)
@@ -19,7 +19,7 @@
 
 require 'csv'
 
-class Import < ActiveRecord::Base
+class Import < ApplicationRecord
   has_many :items, :class_name => 'ImportItem', :dependent => :delete_all
   belongs_to :user
   serialize :settings
index 5f0432e9b451e6b8f14fe3a65e82f3a177c63f3f..2885cacd039e7276d22500be965c28fbf8746b08 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class ImportItem < ActiveRecord::Base
+class ImportItem < ApplicationRecord
   belongs_to :import
 
   validates_presence_of :import_id, :position
index 17802d22774a3ae75b7c87136ca6b15cf2560bfc..670921eb03a1b52ad0adf4cb98067a6c6de2d496 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Issue < ActiveRecord::Base
+class Issue < ApplicationRecord
   include Redmine::SafeAttributes
   include Redmine::Utils::DateCalculation
   include Redmine::I18n
index eadb44891f2e042041a172245fdd0506101d8a0b..d30af17051c63a1080d6c2a5b7dea90252aa9df5 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class IssueCategory < ActiveRecord::Base
+class IssueCategory < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :project
   belongs_to :assigned_to, :class_name => 'Principal'
index 2caaca9badd9a3a366093636cd5299ead8b44602..defd254fdc3f9dbfed49c412946074b27e1e6a01 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class IssueRelation < ActiveRecord::Base
+class IssueRelation < ApplicationRecord
   # Class used to represent the relations of an issue
   class Relations < Array
     include Redmine::I18n
index a93bd5ddc80b75beb462e3743bf18189e3b8c1e5..c8c8c14b1c4fdb6725b1fe732dc1daf983a9395e 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class IssueStatus < ActiveRecord::Base
+class IssueStatus < ApplicationRecord
   include Redmine::SafeAttributes
 
   before_destroy :check_integrity
index c19a63816f0ad2b831f8afccd71a33fc5c0a24dc..9bf12735ec89ec48b1eee43863c8777e1db86d32 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Journal < ActiveRecord::Base
+class Journal < ApplicationRecord
   include Redmine::SafeAttributes
 
   belongs_to :journalized, :polymorphic => true
index 08a38e026dfdec1065fd789a39e34223a20ea18c..5c4fb1dd2ece62bb266df16f7e54a48ebe9ab9ff 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class JournalDetail < ActiveRecord::Base
+class JournalDetail < ApplicationRecord
   belongs_to :journal
 
   def custom_field
index 9e623d5f30bedbbbb7e5b7b4254ba388b1971d27..0ab9f564fa50eaa08ca35aad3c96208046025218 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Member < ActiveRecord::Base
+class Member < ApplicationRecord
   belongs_to :user
   belongs_to :principal, :foreign_key => 'user_id'
   has_many :member_roles, :dependent => :destroy
index a20531f94ebb2ae7a99abe64abe293709a38a690..cb228d05a5dbbf4685f166a50a4b8c58ca759f81 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class MemberRole < ActiveRecord::Base
+class MemberRole < ApplicationRecord
   belongs_to :member
   belongs_to :role
 
index 3f7ed285c069e24c9246263671a07ad4356b766d..28aa6fe886d473edf0167aa0b92a88cc737886c9 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Message < ActiveRecord::Base
+class Message < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :board
   belongs_to :author, :class_name => 'User'
index 8860d6c97c7f8b73a4357a5f4cf1980b50107d40..cbd7023ba156e7a70797810ecf915fe719d06416 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class News < ActiveRecord::Base
+class News < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :project
   belongs_to :author, :class_name => 'User'
index 25a79d768831680ff0f6784371315cb46d866167..1ef1917960d6088a9b6699b62e91821843b6f092 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Principal < ActiveRecord::Base
+class Principal < ApplicationRecord
   self.table_name = "#{table_name_prefix}users#{table_name_suffix}"
 
   # Account statuses
index 58346d3733738c6bac55150025fa5c4087fd09b7..d101bedd4f9f8ea9f4e0eed72f19666620245172 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Project < ActiveRecord::Base
+class Project < ApplicationRecord
   include Redmine::SafeAttributes
   include Redmine::NestedSet::ProjectNestedSet
 
index 1826bd509312da45d3b22ce8c2a8cea575920c9b..558cee23eed84a70c3ef018ecb1a7905e7e62e7c 100644 (file)
@@ -239,7 +239,7 @@ class QueryFilter
   end
 end
 
-class Query < ActiveRecord::Base
+class Query < ApplicationRecord
   class StatementInvalid < ::ActiveRecord::StatementInvalid
   end
 
index 80142739d428d30cb22220150a12e0bd6eb43b4c..9fb8206f63b35283a08e2908c9ad8eb193f7533e 100644 (file)
@@ -19,7 +19,7 @@
 
 class ScmFetchError < StandardError; end
 
-class Repository < ActiveRecord::Base
+class Repository < ApplicationRecord
   include Redmine::Ciphering
   include Redmine::SafeAttributes
 
index 13ebb33248a2df5c417ee8d756a54d63ddc713fd..e67a64554fda312ccc5a18886d22e4bf74d7b848 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Role < ActiveRecord::Base
+class Role < ApplicationRecord
   include Redmine::SafeAttributes
 
   # Custom coder for the permissions attribute that should be an
index 8ee5b1f502f103ada833e0cd45da6f1eb0ae4e76..e649f2deab904a0bceee5b627004429073d199f7 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Setting < ActiveRecord::Base
+class Setting < ApplicationRecord
   PASSWORD_CHAR_CLASSES = {
     'uppercase'     => /[A-Z]/,
     'lowercase'     => /[a-z]/,
index 38504b7740888492dd9a186b9ee1753dd37ec879..66f5c5031bc6744f9af76b6d7f9cf794b01ff2e3 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class TimeEntry < ActiveRecord::Base
+class TimeEntry < ApplicationRecord
   include Redmine::SafeAttributes
   # could have used polymorphic association
   # project association here allows easy loading of time entries at project level with one database trip
index 29340edbad6d862c38357244326699695a4bc0e1..efa8764f2ce01e91fd28950c6b05e1a70bd9a2fd 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Token < ActiveRecord::Base
+class Token < ApplicationRecord
   belongs_to :user
   validates_uniqueness_of :value, :case_sensitive => true
 
index ef2f48b04bdd9f66355374500bcb99847e20df2e..df3d4814edb8eb2414ef5d68d65cdfc6368e33dc 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Tracker < ActiveRecord::Base
+class Tracker < ApplicationRecord
   include Redmine::SafeAttributes
 
   CORE_FIELDS_UNDISABLABLE = %w(project_id tracker_id subject is_private).freeze
index 21992f94540fccdeb6712873a7456ea43ab514cd..17eec682dae09ece01879602a543cc14e236b04d 100644 (file)
@@ -19,7 +19,7 @@
 
 require 'redmine/my_page'
 
-class UserPreference < ActiveRecord::Base
+class UserPreference < ApplicationRecord
   include Redmine::SafeAttributes
 
   belongs_to :user
index 77228826ceb21279d03e7338de2ea6492bbe0852..1968cff423a882d9e568f87a619daf3e8c41008d 100644 (file)
@@ -108,7 +108,7 @@ module FixedIssuesExtension
   end
 end
 
-class Version < ActiveRecord::Base
+class Version < ApplicationRecord
   include Redmine::SafeAttributes
 
   after_update :update_issues_from_sharing_change
index 9f1a09cf04d1247cb87315419c7ca848847660ee..78a63f81c1b2c09336f27b04a4f94adb5dd4c32e 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Watcher < ActiveRecord::Base
+class Watcher < ApplicationRecord
   belongs_to :watchable, :polymorphic => true
   belongs_to :user, :class_name => 'Principal'
 
index 0fddeb3a95dce807d893e78006e05d2524080a4c..4d177050879e726cb530889c8e23640c2780b53e 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class Wiki < ActiveRecord::Base
+class Wiki < ApplicationRecord
   include Redmine::SafeAttributes
   belongs_to :project
   has_many :pages, lambda {order(Arel.sql('LOWER(title)').asc)}, :class_name => 'WikiPage', :dependent => :destroy
index d6a317a323d9c9bd153a565e9e03164038f86a71..4ec4bb438f4b645d425c5ecf0a6ba82c8f203f9d 100644 (file)
@@ -19,7 +19,7 @@
 
 require 'zlib'
 
-class WikiContent < ActiveRecord::Base
+class WikiContent < ApplicationRecord
   self.locking_column = 'version'
   belongs_to :page, :class_name => 'WikiPage'
   belongs_to :author, :class_name => 'User'
index 85bd84fe7b94554ea6b491846321d7488cedda12..bb7570806ee2a53dc090abb48a362e677f825fc6 100644 (file)
@@ -19,7 +19,7 @@
 
 require 'zlib'
 
-class WikiContentVersion < ActiveRecord::Base
+class WikiContentVersion < ApplicationRecord
   belongs_to :page, :class_name => 'WikiPage'
   belongs_to :author, :class_name => 'User'
 
index ea9d079e82fa696d37589ac2db523a68aa927d37..290ee779829c077e59a208a0c5afc64fd1251c78 100644 (file)
@@ -19,7 +19,7 @@
 
 require 'redmine/string_array_diff/diff'
 
-class WikiPage < ActiveRecord::Base
+class WikiPage < ApplicationRecord
   include Redmine::SafeAttributes
 
   belongs_to :wiki
index f338e20b0290d25a84522e26a4fd9cf35ec31bc5..564be06f2809abd58de87bf51d48a58afd9d970d 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class WikiRedirect < ActiveRecord::Base
+class WikiRedirect < ApplicationRecord
   belongs_to :wiki
 
   validates_presence_of :wiki_id, :title, :redirects_to
index ec4e506c8d31d8b39edbb504b819c41125e02cb7..dd0a824d62f7288b20de6b47ea5cb54091659073 100644 (file)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-class WorkflowRule < ActiveRecord::Base
+class WorkflowRule < ApplicationRecord
   self.table_name = "#{table_name_prefix}workflows#{table_name_suffix}"
 
   belongs_to :role
index e9d15cae536ca333878b6accedd1f100e694e5dd..c298b96099fa98634f9c23d16a56fa9fe3faa8c7 100644 (file)
@@ -1,22 +1,6 @@
 # frozen_string_literal: true
 
 module ActiveRecord
-  class Base
-    # Translate attribute names for validation errors display
-    def self.human_attribute_name(attr, options = {})
-      prepared_attr = attr.to_s.delete_suffix('_id').sub(/^.+\./, '')
-      class_prefix = name.underscore.tr('/', '_')
-
-      redmine_default = [
-        :"field_#{class_prefix}_#{prepared_attr}",
-        :"field_#{prepared_attr}"
-      ]
-
-      options[:default] = redmine_default + Array(options[:default])
-
-      super
-    end
-  end
 
   # Undefines private Kernel#open method to allow using `open` scopes in models.
   # See Defect #11545 (http://www.redmine.org/issues/11545) for details.
index 78d801304d6aa82931a764126c1ff78fc39b6326..34310647ce7aaf3a63d0d1a9d0f22a927d55d756 100644 (file)
@@ -1,4 +1,4 @@
-class Meeting < ActiveRecord::Base
+class Meeting < ApplicationRecord
   belongs_to :project
 
   acts_as_event :title => Proc.new {|o| "#{o.scheduled_on} Meeting"},
index 2715a7bbe6a853b7b50062eccdf395d53d484a2b..9fafbec77356ce0e87613a724db3ade74aa3ceab 100644 (file)
@@ -63,6 +63,6 @@ class RedminePluginModelGenerator < Rails::Generators::NamedBase
   end
 
   def parent_class_name
-    options[:parent] || "ActiveRecord::Base"
+    options[:parent] || "ApplicationRecord"
   end
 end
index eaf15886daa6cb328cb61ce40c93ce9de5781c52..47f23c5f1eff9628c2bc85dd16a4db76284a7592 100644 (file)
@@ -18,4 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require_relative 'lib/acts_as_activity_provider'
-ActiveRecord::Base.send(:include, Redmine::Acts::ActivityProvider)
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send(:include, Redmine::Acts::ActivityProvider)
+end
index e621b10abb4b31b2b23507f32f9634c4d9ca825e..a19ae059542cebe06889cdfb672f929528415382 100644 (file)
@@ -18,4 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require_relative 'lib/acts_as_attachable'
-ActiveRecord::Base.send(:include, Redmine::Acts::Attachable)
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send(:include, Redmine::Acts::Attachable)
+end
index 7a85ef1607696ed5a286b8bec8c18e36ce6aab59..27bdb2f84a8ccf6790eed9cc12d08c0ce4514741 100644 (file)
@@ -18,4 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require_relative 'lib/acts_as_customizable'
-ActiveRecord::Base.send(:include, Redmine::Acts::Customizable)
+Rails.application.reloader.to_prepare do
+    ApplicationRecord.send(:include, Redmine::Acts::Customizable)
+end
\ No newline at end of file
index 2669f1cf14dc6851dfd70c421a866df0be6775a2..2b4feb6074fae5c96a7b7a214b5c4dabf0672114 100644 (file)
@@ -18,4 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require_relative 'lib/acts_as_event'
-ActiveRecord::Base.send(:include, Redmine::Acts::Event)
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send(:include, Redmine::Acts::Event)
+end
\ No newline at end of file
index a268122d86389e45482f85ecb0df6b507a19f755..18598688be47cb320a119e7a52c09d9950a6a785 100644 (file)
@@ -18,4 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require_relative 'lib/acts_as_searchable'
-ActiveRecord::Base.send(:include, Redmine::Acts::Searchable)
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send(:include, Redmine::Acts::Searchable)
+end
index a6cc6a904a9d9f9b253c46a3ba4beadb00f24b5e..a10826ff51c15b25232eb85cf141ab1d135921bd 100644 (file)
@@ -4,7 +4,7 @@ acts_as_tree
 Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
 association. This requires that you have a foreign key column, which by default is called +parent_id+.
 
-  class Category < ActiveRecord::Base
+  class Category < ApplicationRecord
     acts_as_tree :order => "name"
   end
 
index 36d1193d0b255d846d3043f685ae0b9c151d4461..e7f63c70a9f85b1c88359adbe90905b5b8eb6d78 100644 (file)
@@ -1,4 +1,6 @@
 # frozen_string_literal: true
 
 require_relative 'lib/active_record/acts/tree'
-ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send :include, ActiveRecord::Acts::Tree
+end
index 14dce355a8656f5ff33a7b4388f0e8b20f172781..831056d5960d99384100ac8cb72fd212748a3182 100644 (file)
@@ -10,7 +10,7 @@ module ActiveRecord
       # Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
       # association. This requires that you have a foreign key column, which by default is called +parent_id+.
       #
-      #   class Category < ActiveRecord::Base
+      #   class Category < ApplicationRecord
       #     acts_as_tree :order => "name"
       #   end
       #
index 94899f9407717892c2b40b84c3cfb0fb996672e9..337411151d4b363106e0ecddf8dff67731810822 100644 (file)
@@ -42,7 +42,7 @@ def teardown_db
   end
 end
 
-class Mixin < ActiveRecord::Base
+class Mixin < ApplicationRecord
 end
 
 class TreeMixin < Mixin
index 6056987c7191d0db6a98707a42f986a8caf9e250..565e27e1d6aa22a235019a387329514a6d2cc944 100644 (file)
@@ -19,4 +19,6 @@
 
 # Include hook code here
 require_relative 'lib/acts_as_watchable'
-ActiveRecord::Base.send(:include, Redmine::Acts::Watchable)
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send(:include, Redmine::Acts::Watchable)
+end
index a312000f5cb75c22e6a223328ad53bf6cd9337ad..648eeb2823744c66efaf6404ec89a205dbf495d6 100644 (file)
@@ -1,4 +1,6 @@
 # frozen_string_literal: true
 
 require_relative 'lib/gravatar'
-ActionView::Base.send :include, GravatarHelper::PublicMethods
+Rails.application.reloader.to_prepare do
+  ApplicationRecord.send :include, GravatarHelper::PublicMethods
+end
index 64333672a150202b3246d44c5b9e8d3ce68d599f..3042eaa9480b2d4a98748e7945be3021f07c3c7f 100644 (file)
@@ -20,9 +20,9 @@
 module Redmine
   module Preparation
     def self.prepare
-      ActiveRecord::Base.include Redmine::Acts::Positioned
-      ActiveRecord::Base.include Redmine::Acts::Mentionable
-      ActiveRecord::Base.include Redmine::I18n
+      ApplicationRecord.include Redmine::Acts::Positioned
+      ApplicationRecord.include Redmine::Acts::Mentionable
+      ApplicationRecord.include Redmine::I18n
 
       Scm::Base.add "Subversion"
       Scm::Base.add "Mercurial"
index 57eff0662711c95becf3f26f6058a95901efe2a5..db1b60ca3d0f8e355312a9581aa829387e465b50 100644 (file)
@@ -27,16 +27,16 @@ class PatchesTest < ActiveSupport::TestCase
     Setting.default_language = 'en'
   end
 
-  test "ActiveRecord::Base.human_attribute_name should transform name to field_name" do
-    assert_equal l('field_last_login_on'), ActiveRecord::Base.human_attribute_name('last_login_on')
+  test "ApplicationRecord.human_attribute_name should transform name to field_name" do
+    assert_equal l('field_last_login_on'), ApplicationRecord.human_attribute_name('last_login_on')
   end
 
-  test "ActiveRecord::Base.human_attribute_name should cut extra _id suffix for better validation" do
-    assert_equal l('field_last_login_on'), ActiveRecord::Base.human_attribute_name('last_login_on_id')
+  test "ApplicationRecord.human_attribute_name should cut extra _id suffix for better validation" do
+    assert_equal l('field_last_login_on'), ApplicationRecord.human_attribute_name('last_login_on_id')
   end
 
-  test "ActiveRecord::Base.human_attribute_name should default to humanized value if no translation has been found (useful for custom fields)" do
-    assert_equal 'Patch name', ActiveRecord::Base.human_attribute_name('Patch name')
+  test "ApplicationRecord.human_attribute_name should default to humanized value if no translation has been found (useful for custom fields)" do
+    assert_equal 'Patch name', ApplicationRecord.human_attribute_name('Patch name')
   end
 
   test 'ActionView::Helpers::FormHelper.date_field should add max=9999-12-31 to limit year value to 4 digits by default' do