]> source.dussan.org Git - redmine.git/commitdiff
Force TimeEntry#hours default to nil (#3075, #4449).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 23 Dec 2009 20:05:46 +0000 (20:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 23 Dec 2009 20:05:46 +0000 (20:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3232 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb
test/unit/time_entry_test.rb

index 91996ba2f22033ae50dbdcd0b92b7e6641595707..73f39f949ea0b2a06b1bbcd71c48593e09e4d161 100644 (file)
@@ -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
   
index 7ac1c02a365eb8eeb41fe79ea8b934316df5edf4..3c135510ace5e3443a2ae3826ef8d545eab1809f 100644 (file)
@@ -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