diff test/unit/time_entry_test.rb @ 524:1248a47e81b3 feature_36

Merge from branch "luisf"
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 25 Jul 2011 14:39:38 +0100
parents 07fa8a8b56a8
children cbb26bc654de
line wrap: on
line diff
--- a/test/unit/time_entry_test.rb	Fri Jul 15 17:21:05 2011 +0100
+++ b/test/unit/time_entry_test.rb	Mon Jul 25 14:39:38 2011 +0100
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-require File.dirname(__FILE__) + '/../test_helper'
+require File.expand_path('../../test_helper', __FILE__)
 
 class TimeEntryTest < ActiveSupport::TestCase
   fixtures :issues, :projects, :users, :time_entries
@@ -48,6 +48,42 @@
   def test_hours_should_default_to_nil
     assert_nil TimeEntry.new.hours
   end
+  
+  def test_spent_on_with_blank
+    c = TimeEntry.new
+    c.spent_on = ''
+    assert_nil c.spent_on
+  end
+  
+  def test_spent_on_with_nil
+    c = TimeEntry.new
+    c.spent_on = nil
+    assert_nil c.spent_on
+  end
+  
+  def test_spent_on_with_string
+    c = TimeEntry.new
+    c.spent_on = "2011-01-14"
+    assert_equal Date.parse("2011-01-14"), c.spent_on
+  end
+  
+  def test_spent_on_with_invalid_string
+    c = TimeEntry.new
+    c.spent_on = "foo"
+    assert_nil c.spent_on
+  end
+  
+  def test_spent_on_with_date
+    c = TimeEntry.new
+    c.spent_on = Date.today
+    assert_equal Date.today, c.spent_on
+  end
+  
+  def test_spent_on_with_time
+    c = TimeEntry.new
+    c.spent_on = Time.now
+    assert_equal Date.today, c.spent_on
+  end
 
   context "#earilest_date_for_project" do
     setup do