summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-23 20:05:46 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-23 20:05:46 +0000
commitd63784569f4989f32289ac074a4e9eaec11b6420 (patch)
tree890817582ed592257aa050ba1767c6252f4e5176
parent5e1dc78d75391e3b0b628af06840ffc6674bd1c1 (diff)
downloadredmine-d63784569f4989f32289ac074a4e9eaec11b6420.tar.gz
redmine-d63784569f4989f32289ac074a4e9eaec11b6420.zip
Force TimeEntry#hours default to nil (#3075, #4449).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3232 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/time_entry.rb1
-rw-r--r--test/unit/time_entry_test.rb4
2 files changed, 5 insertions, 0 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 91996ba2f..73f39f949 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -44,6 +44,7 @@ class TimeEntry < ActiveRecord::Base
if default_activity = TimeEntryActivity.default
self.activity_id = default_activity.id
end
+ self.hours = nil if hours == 0
end
end
diff --git a/test/unit/time_entry_test.rb b/test/unit/time_entry_test.rb
index 7ac1c02a3..3c135510a 100644
--- a/test/unit/time_entry_test.rb
+++ b/test/unit/time_entry_test.rb
@@ -44,4 +44,8 @@ class TimeEntryTest < ActiveSupport::TestCase
assert_equal v, t.hours, "Converting #{k} failed:"
end
end
+
+ def test_hours_should_default_to_nil
+ assert_nil TimeEntry.new.hours
+ end
end