summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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