summaryrefslogtreecommitdiffstats
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-09 09:12:29 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-09 09:12:29 +0000
commitf2520385e44587c9b712161ff5f5c6cb9a20fe5b (patch)
treeacbf593b7e0dac4dfb30e3020ab1a78f5e97bad9 /app/models/issue.rb
parent1de2a0b7c7b99f5ea4c30b67e736caf63943ac19 (diff)
downloadredmine-f2520385e44587c9b712161ff5f5c6cb9a20fe5b.tar.gz
redmine-f2520385e44587c9b712161ff5f5c6cb9a20fe5b.zip
Fixes tracker_id and custom_field_values assignment order for issues (#4353).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3139 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index e98369d06..a0f47fdb8 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -142,8 +142,22 @@ class Issue < ActiveRecord::Base
def tracker_id=(tid)
self.tracker = nil
write_attribute(:tracker_id, tid)
+ result = write_attribute(:tracker_id, tid)
+ @custom_field_values = nil
+ result
end
+ # Overrides attributes= so that tracker_id gets assigned first
+ def attributes_with_tracker_first=(new_attributes, *args)
+ return if new_attributes.nil?
+ new_tracker_id = new_attributes['tracker_id'] || new_attributes[:tracker_id]
+ if new_tracker_id
+ self.tracker_id = new_tracker_id
+ end
+ self.attributes_without_tracker_first = new_attributes, *args
+ end
+ alias_method_chain :attributes=, :tracker_first
+
def estimated_hours=(h)
write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
end