Merged r14049 (#19197).

git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@14057 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2015-03-08 09:41:42 +00:00
parent 662bd633ce
commit 223ffd50d5
2 changed files with 10 additions and 2 deletions

View File

@@ -784,12 +784,12 @@ class Issue < ActiveRecord::Base
end
end
# Returns the previous assignee if changed
# Returns the previous assignee (user or group) if changed
def assigned_to_was
# assigned_to_id_was is reset before after_save callbacks
user_id = @previous_assigned_to_id || assigned_to_id_was
if user_id && user_id != assigned_to_id
@assigned_to_was ||= User.find_by_id(user_id)
@assigned_to_was ||= Principal.find_by_id(user_id)
end
end

View File

@@ -2416,4 +2416,12 @@ class IssueTest < ActiveSupport::TestCase
assert issue.save!
assert_equal IssueStatus.find(2), issue.status_was
end
def test_assigned_to_was_with_a_group
group = Group.find(10)
issue = Issue.generate!(:assigned_to => group)
issue.reload.assigned_to = nil
assert_equal group, issue.assigned_to_was
end
end