Mercurial > hg > soundsoftware-site
diff test/unit/time_entry_test.rb @ 22:40f7cfd4df19
* Update to SVN trunk rev 4173
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 24 Sep 2010 14:06:04 +0100 |
parents | 513646585e45 |
children | af80e5618e9b |
line wrap: on
line diff
--- a/test/unit/time_entry_test.rb Wed Aug 25 16:30:24 2010 +0100 +++ b/test/unit/time_entry_test.rb Fri Sep 24 14:06:04 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