diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-17 09:30:17 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-17 09:30:17 +0000 |
commit | 7b7427b46eebba1faa8bb6574852c872593b78c1 (patch) | |
tree | 13e0f841f1385c11d2aeae1a740dd959ada2a240 /app/models | |
parent | 7a1af68178a1d7d57218228d9a5fd57cbfd04717 (diff) | |
download | redmine-7b7427b46eebba1faa8bb6574852c872593b78c1.tar.gz redmine-7b7427b46eebba1faa8bb6574852c872593b78c1.zip |
Adds Issue#status_was that returns the initial issue status.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11412 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index fd7cc0b50..e01dcc95a 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -155,6 +155,13 @@ class Issue < ActiveRecord::Base end end + def create_or_update + super + ensure + @status_was = nil + end + private :create_or_update + # AR#Persistence#destroy would raise and RecordNotFound exception # if the issue was already deleted or updated (non matching lock_version). # This is a problem when bulk deleting issues or deleting a project @@ -637,6 +644,14 @@ class Issue < ActiveRecord::Base scope end + # Returns the initial status of the issue + # Returns nil for a new issue + def status_was + if status_id_was && status_id_was.to_i > 0 + @status_was ||= IssueStatus.find_by_id(status_id_was) + end + end + # Return true if the issue is closed, otherwise false def closed? self.status.is_closed? @@ -657,9 +672,7 @@ class Issue < ActiveRecord::Base # Return true if the issue is being closed def closing? if !new_record? && status_id_changed? - status_was = IssueStatus.find_by_id(status_id_was) - status_new = IssueStatus.find_by_id(status_id) - if status_was && status_new && !status_was.is_closed? && status_new.is_closed? + if status_was && status && !status_was.is_closed? && status.is_closed? return true end end |