summaryrefslogtreecommitdiffstats
path: root/test/unit/time_entry_test.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-14 19:02:25 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-14 19:02:25 +0000
commitcdfc57d5442f72d62437f52af480049c943ecbf8 (patch)
tree576cbf92e5bdeec589544476cc83de216adda120 /test/unit/time_entry_test.rb
parent8900797adaf29adc447925b800d5457ca941795f (diff)
downloadredmine-cdfc57d5442f72d62437f52af480049c943ecbf8.tar.gz
redmine-cdfc57d5442f72d62437f52af480049c943ecbf8.zip
Change the TimelogController's to/from dates based on the project time entries
Instead of looking for the earliest and latest time entry system wide for the dates in the form, now TimelogController will only look at the time entries for the current project (and parent/sub projects). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4087 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/time_entry_test.rb')
-rw-r--r--test/unit/time_entry_test.rb45
1 files changed, 39 insertions, 6 deletions
diff --git a/test/unit/time_entry_test.rb b/test/unit/time_entry_test.rb
index a541fc41f..3069f9368 100644
--- a/test/unit/time_entry_test.rb
+++ b/test/unit/time_entry_test.rb
@@ -50,17 +50,50 @@ class TimeEntryTest < ActiveSupport::TestCase
end
context "#earilest_date_for_project" do
- should "return the lowest spent_on value that is visible to the current user" do
+ setup do
User.current = nil
- assert_equal "2007-03-12", TimeEntry.earilest_date_for_project.to_s
+ @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
- should "return the highest spent_on value that is visible to the current user" do
+ setup do
User.current = nil
- assert_equal "2007-04-22", TimeEntry.latest_date_for_project.to_s
+ @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
- 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