]> source.dussan.org Git - redmine.git/commitdiff
Merged r4708 and r4709 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 30 Jan 2011 06:00:56 +0000 (06:00 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 30 Jan 2011 06:00:56 +0000 (06:00 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.1-stable@4766 e93f8b46-1217-0410-a6f0-8f06a7374b81

.project [new file with mode: 0644]
app/models/time_entry.rb
test/unit/time_entry_test.rb

diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..67a673a
--- /dev/null
+++ b/.project
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>1.1-stable</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.rubypeople.rdt.core.rubybuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>com.aptana.ide.core.unifiedBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>com.aptana.ide.project.nature.web</nature>\r
+               <nature>org.rubypeople.rdt.core.rubynature</nature>\r
+               <nature>org.radrails.rails.core.railsnature</nature>\r
+       </natures>\r
+</projectDescription>\r
index b832277da167a4a483d6f8b866bb3fee4ac97258..ade80286837c8908daa85b1aa1d728322f64a240 100644 (file)
@@ -66,6 +66,9 @@ class TimeEntry < ActiveRecord::Base
   # these attributes make time aggregations easier
   def spent_on=(date)
     super
+    if spent_on.is_a?(Time)
+      self.spent_on = spent_on.to_date
+    end
     self.tyear = spent_on ? spent_on.year : nil
     self.tmonth = spent_on ? spent_on.month : nil
     self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil
index ef4ad81b27899f3f719ec5d28d3af33ef16163ed..bd49494c62bdffe386e47e51bd9d43e247981861 100644 (file)
@@ -48,6 +48,42 @@ class TimeEntryTest < ActiveSupport::TestCase
   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