diff test/unit/.svn/text-base/time_entry_test.rb.svn-base @ 25:9fd6221709a6 luisf

* Merge cannam branch
author Chris Cannam
date Fri, 24 Sep 2010 15:51:28 +0100
parents 40f7cfd4df19
children af80e5618e9b
line wrap: on
line diff
--- a/test/unit/.svn/text-base/time_entry_test.rb.svn-base	Fri Sep 24 15:33:13 2010 +0100
+++ b/test/unit/.svn/text-base/time_entry_test.rb.svn-base	Fri Sep 24 15:51:28 2010 +0100
@@ -48,4 +48,52 @@
   def test_hours_should_default_to_nil
     assert_nil TimeEntry.new.hours
   end
+
+  context "#earilest_date_for_project" do
+    setup do
+      User.current = nil
+      @public_project = Project.generate!(:is_public => true)
+      @issue = Issue.generate_for_project!(@public_project)
+      TimeEntry.generate!(:spent_on => '2010-01-01',
+                          :issue => @issue,
+                          :project => @public_project)
+    end
+    
+    context "without a project" do
+      should "return the lowest spent_on value that is visible to the current user" do
+        assert_equal "2007-03-12", TimeEntry.earilest_date_for_project.to_s
+      end
+    end
+
+    context "with a project" do
+      should "return the lowest spent_on value that is visible to the current user for that project and it's subprojects only" do
+        assert_equal "2010-01-01", TimeEntry.earilest_date_for_project(@public_project).to_s
+      end
+    end
+      
+  end
+
+  context "#latest_date_for_project" do
+    setup do
+      User.current = nil
+      @public_project = Project.generate!(:is_public => true)
+      @issue = Issue.generate_for_project!(@public_project)
+      TimeEntry.generate!(:spent_on => '2010-01-01',
+                          :issue => @issue,
+                          :project => @public_project)
+    end
+
+    context "without a project" do
+      should "return the highest spent_on value that is visible to the current user" do
+        assert_equal "2010-01-01", TimeEntry.latest_date_for_project.to_s
+      end
+    end
+
+    context "with a project" do
+      should "return the highest spent_on value that is visible to the current user for that project and it's subprojects only" do
+        project = Project.find(1)
+        assert_equal "2007-04-22", TimeEntry.latest_date_for_project(project).to_s
+      end
+    end
+  end  
 end