mirror of
https://github.com/redmine/redmine.git
synced 2026-01-15 03:52:51 +01:00
Fix RuboCop offense Rails/ActiveRecordCallbacksOrder (#39889).
git-svn-id: https://svn.redmine.org/redmine/trunk@22879 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --exclude-limit 20 --no-offense-counts --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.64.0.
|
||||
# using RuboCop version 1.64.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
@@ -454,23 +454,6 @@ Naming/VariableNumber:
|
||||
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
|
||||
- 'test/unit/project_test.rb'
|
||||
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/ActiveRecordCallbacksOrder:
|
||||
Exclude:
|
||||
- 'app/models/attachment.rb'
|
||||
- 'app/models/change.rb'
|
||||
- 'app/models/changeset.rb'
|
||||
- 'app/models/enumeration.rb'
|
||||
- 'app/models/issue.rb'
|
||||
- 'app/models/issue_status.rb'
|
||||
- 'app/models/member_role.rb'
|
||||
- 'app/models/project.rb'
|
||||
- 'app/models/user.rb'
|
||||
- 'app/models/version.rb'
|
||||
- 'app/models/wiki_page.rb'
|
||||
|
||||
# Configuration parameters: Severity, Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/ActiveRecordOverride:
|
||||
|
||||
@@ -84,9 +84,9 @@ class Attachment < ApplicationRecord
|
||||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_create :files_to_final_location
|
||||
after_rollback :delete_from_disk, :on => :create
|
||||
after_commit :delete_from_disk, :on => :destroy
|
||||
after_commit :reuse_existing_file_if_possible, :on => :create
|
||||
after_rollback :delete_from_disk, :on => :create
|
||||
|
||||
safe_attributes 'filename', 'content_type', 'description'
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ class Change < ApplicationRecord
|
||||
belongs_to :changeset
|
||||
|
||||
validates_presence_of :changeset_id, :action, :path
|
||||
before_save :init_path
|
||||
before_validation :replace_invalid_utf8_of_path
|
||||
before_save :init_path
|
||||
|
||||
def replace_invalid_utf8_of_path
|
||||
self.path = Redmine::CodesetUtil.replace_invalid_utf8(self.path)
|
||||
|
||||
@@ -60,8 +60,8 @@ class Changeset < ApplicationRecord
|
||||
where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
|
||||
end)
|
||||
|
||||
after_create :scan_for_issues
|
||||
before_create :before_create_cs
|
||||
after_create :scan_for_issues
|
||||
|
||||
def revision=(r)
|
||||
write_attribute :revision, (r.nil? ? nil : r.to_s)
|
||||
|
||||
@@ -28,8 +28,8 @@ class Enumeration < ApplicationRecord
|
||||
acts_as_customizable
|
||||
acts_as_tree
|
||||
|
||||
before_destroy :check_integrity
|
||||
before_save :check_default
|
||||
before_destroy :check_integrity
|
||||
after_save :update_children_name
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
@@ -21,6 +21,8 @@ class Issue < ApplicationRecord
|
||||
include Redmine::SafeAttributes
|
||||
include Redmine::Utils::DateCalculation
|
||||
include Redmine::I18n
|
||||
before_validation :default_assign, on: :create
|
||||
before_validation :clear_disabled_fields
|
||||
before_save :set_parent_id
|
||||
include Redmine::NestedSet::IssueNestedSet
|
||||
|
||||
@@ -107,8 +109,6 @@ class Issue < ApplicationRecord
|
||||
end
|
||||
end)
|
||||
|
||||
before_validation :default_assign, on: :create
|
||||
before_validation :clear_disabled_fields
|
||||
before_save :close_duplicates, :update_done_ratio_from_issue_status,
|
||||
:force_updated_on_change, :update_closed_on
|
||||
after_save do |issue|
|
||||
@@ -116,11 +116,11 @@ class Issue < ApplicationRecord
|
||||
issue.send :after_project_change
|
||||
end
|
||||
end
|
||||
after_destroy :update_parent_attributes
|
||||
after_save :reschedule_following_issues, :update_nested_set_attributes,
|
||||
:update_parent_attributes, :delete_selected_attachments, :create_journal
|
||||
# Should be after_create but would be called before previous after_save callbacks
|
||||
after_save :after_create_from_copy
|
||||
after_destroy :update_parent_attributes
|
||||
# add_auto_watcher needs to run before sending notifications, thus it needs
|
||||
# to be added after send_notification (after_ callbacks are run in inverse order)
|
||||
# https://api.rubyonrails.org/v5.2.3/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-set_callback
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
class IssueStatus < ApplicationRecord
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
after_update :handle_is_closed_change
|
||||
before_destroy :check_integrity
|
||||
has_many :workflows, :class_name => 'WorkflowTransition', :foreign_key => "old_status_id"
|
||||
has_many :workflow_transitions_as_new_status, :class_name => 'WorkflowTransition', :foreign_key => "new_status_id"
|
||||
acts_as_positioned
|
||||
|
||||
after_update :handle_is_closed_change
|
||||
before_destroy :delete_workflow_rules
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
@@ -21,9 +21,9 @@ class MemberRole < ApplicationRecord
|
||||
belongs_to :member
|
||||
belongs_to :role
|
||||
|
||||
after_create :add_role_to_group_users, :add_role_to_subprojects
|
||||
after_destroy :remove_member_if_empty
|
||||
|
||||
after_create :add_role_to_group_users, :add_role_to_subprojects
|
||||
after_destroy :remove_inherited_roles
|
||||
|
||||
validates_presence_of :role
|
||||
|
||||
@@ -87,13 +87,13 @@ class Project < ApplicationRecord
|
||||
validates_exclusion_of :identifier, :in => %w(new)
|
||||
validate :validate_parent
|
||||
|
||||
after_update :update_versions_from_hierarchy_change,
|
||||
:if => proc {|project| project.saved_change_to_parent_id?}
|
||||
before_destroy :delete_all_members
|
||||
after_save :update_inherited_members,
|
||||
:if => proc {|project| project.saved_change_to_inherit_members?}
|
||||
after_save :remove_inherited_member_roles, :add_inherited_member_roles,
|
||||
:if => proc {|project| project.saved_change_to_parent_id?}
|
||||
after_update :update_versions_from_hierarchy_change,
|
||||
:if => proc {|project| project.saved_change_to_parent_id?}
|
||||
before_destroy :delete_all_members
|
||||
|
||||
scope :has_module, (lambda do |mod|
|
||||
where("#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s)
|
||||
|
||||
@@ -126,11 +126,11 @@ class User < Principal
|
||||
self.valid_statuses = [STATUS_ACTIVE, STATUS_REGISTERED, STATUS_LOCKED]
|
||||
|
||||
before_validation :instantiate_email_address
|
||||
before_create :set_mail_notification
|
||||
before_save :generate_password_if_needed, :update_hashed_password
|
||||
before_create :set_mail_notification
|
||||
before_destroy :remove_references_before_destroy
|
||||
after_save :update_notified_project_ids, :destroy_tokens, :deliver_security_notification
|
||||
after_destroy :deliver_security_notification
|
||||
after_save :update_notified_project_ids, :destroy_tokens, :deliver_security_notification
|
||||
|
||||
scope :admin, (lambda do |*args|
|
||||
admin = args.size > 0 ? !!args.first : true
|
||||
|
||||
@@ -123,8 +123,8 @@ class Version < ApplicationRecord
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
after_update :update_issues_from_sharing_change
|
||||
after_save :update_default_project_version
|
||||
before_destroy :nullify_projects_default_version
|
||||
after_save :update_default_project_version
|
||||
|
||||
belongs_to :project
|
||||
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify, :extend => FixedIssuesExtension
|
||||
|
||||
@@ -58,8 +58,8 @@ class WikiPage < ApplicationRecord
|
||||
validates_associated :content
|
||||
|
||||
validate :validate_parent_title
|
||||
before_destroy :delete_redirects
|
||||
before_save :handle_rename_or_move, :update_wiki_start_page
|
||||
before_destroy :delete_redirects
|
||||
after_save :handle_children_move, :delete_selected_attachments
|
||||
|
||||
# eager load information about last updates, without loading text
|
||||
|
||||
Reference in New Issue
Block a user