replace deprecated references to attribute_was/changed

pull/6116/head
Jens Ulferts 7 years ago
parent 4aa0cca21c
commit 486046681d
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 33
      app/models/message.rb
  2. 8
      app/models/relation/hierarchy_paths.rb
  3. 12
      app/models/version.rb
  4. 5
      app/models/wiki_content.rb

@ -67,10 +67,10 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher,
:update_last_reply_in_parent,
:send_message_posted_mail
after_update :update_ancestors
after_update :update_ancestors, if: :saved_change_to_board_id?
after_destroy :reset_counters
scope :visible, -> (*args) {
scope :visible, ->(*args) {
includes(board: :project)
.references(:projects)
.merge(Project.allowed_to(args.first || User.current, :view_messages))
@ -90,11 +90,9 @@ class Message < ActiveRecord::Base
end
def set_sticked_on_date
if sticky?
self.sticked_on = sticked_on.nil? ? Time.now : sticked_on
else
self.sticked_on = nil
end
self.sticked_on = if sticky?
sticked_on.nil? ? Time.now : sticked_on
end
end
def update_last_reply_in_parent
@ -104,15 +102,6 @@ class Message < ActiveRecord::Base
board.reset_counters!
end
def update_ancestors
if board_id_changed?
Message.where(['id = ? OR parent_id = ?', root.id, root.id])
.update_all("board_id = #{board_id}")
Board.reset_counters!(board_id_was)
Board.reset_counters!(board_id)
end
end
def reset_counters
board.reset_counters!
end
@ -135,6 +124,18 @@ class Message < ActiveRecord::Base
private
def update_ancestors
with_id = Message.where(id: root.id)
with_parent_id = Message.where(parent_id: root.id)
with_id
.or(with_parent_id)
.update_all("board_id = #{board_id}")
Board.reset_counters!(board_id_was)
Board.reset_counters!(board_id)
end
def add_author_as_watcher
Watcher.create(watchable: root, user: author)
# update watchers and watcher_users

@ -63,20 +63,20 @@ module Relation::HierarchyPaths
remove_hierarchy_path
elsif now_hierarchy_relation_or_former_id_changed?
add_hierarchy_path
elsif hierarchy_relatin_and_to_id_changed?
elsif hierarchy_relation_and_to_id_changed?
alter_hierarchy_path
end
end
def was_hierarchy_relation?
relation_type_changed? && relation_type_was == Relation::TYPE_HIERARCHY
saved_change_to_relation_type? && relation_type_before_last_save == Relation::TYPE_HIERARCHY
end
def now_hierarchy_relation_or_former_id_changed?
(relation_type_changed? || from_id_changed?) && hierarchy?
(saved_change_to_relation_type? || saved_change_to_from_id?) && hierarchy?
end
def hierarchy_relatin_and_to_id_changed?
def hierarchy_relation_and_to_id_changed?
hierarchy? && to_id_changed?
end

@ -33,7 +33,7 @@ class Version < ActiveRecord::Base
include Version::ProjectSharing
after_update :update_issues_from_sharing_change
after_update :update_issues_from_sharing_change, if: :saved_change_to_sharing?
belongs_to :project
has_many :fixed_issues, class_name: 'WorkPackage', foreign_key: 'fixed_version_id', dependent: :nullify
has_many :work_packages, foreign_key: :fixed_version_id
@ -228,12 +228,10 @@ class Version < ActiveRecord::Base
# Update the issue's fixed versions. Used if a version's sharing changes.
def update_issues_from_sharing_change
if sharing_changed?
if VERSION_SHARINGS.index(sharing_was).nil? ||
VERSION_SHARINGS.index(sharing).nil? ||
VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing)
WorkPackage.update_versions_from_sharing_change self
end
if VERSION_SHARINGS.index(sharing_was).nil? ||
VERSION_SHARINGS.index(sharing).nil? ||
VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing)
WorkPackage.update_versions_from_sharing_change self
end
end

@ -39,7 +39,7 @@ class WikiContent < ActiveRecord::Base
before_save :comments_to_journal_notes
after_create :send_content_added_mail
after_update :send_content_updated_mail
after_update :send_content_updated_mail, if: :saved_change_to_text?
acts_as_journalized
@ -94,8 +94,7 @@ class WikiContent < ActiveRecord::Base
end
def send_content_updated_mail
return unless text_changed? &&
Setting.notified_events.include?('wiki_content_updated')
return unless Setting.notified_events.include?('wiki_content_updated')
update_recipients.uniq.each do |user|
UserMailer.wiki_content_updated(user, self, User.current).deliver_now

Loading…
Cancel
Save