Index: issue.rb =================================================================== --- issue.rb (revision 16970) +++ issue.rb (working copy) @@ -104,6 +104,9 @@ end } + before_save { @in_before_save_callback = true } + after_save { @in_before_save_callback = false } + before_validation :default_assign, on: :create before_validation :clear_disabled_fields before_save :close_duplicates, :update_done_ratio_from_issue_status, @@ -1009,16 +1012,12 @@ # Returns the original tracker def tracker_was - Tracker.find_by_id(tracker_id_in_database) + Tracker.find_by(:id => tracker_id_was) end - # Returns the previous assignee whenever we're before the save - # or in after_* callbacks + # Returns the previous assignee def previous_assignee - # This is how ActiveRecord::AttributeMethods::Dirty checks if we're in a after_* callback - if previous_assigned_to_id = mutation_tracker.equal?(mutations_from_database) ? assigned_to_id_in_database : assigned_to_id_before_last_save - Principal.find_by_id(previous_assigned_to_id) - end + Principal.find_by(:id => @in_before_save_callback ? assigned_to_id_before_last_save : assigned_to_id_was) end # Returns the users that should be notified