@@ -260,8 +260,8 private | |||
|
260 | 260 | end |
|
261 | 261 | |
|
262 | 262 | @from, @to = @to, @from if @from && @to && @from > @to |
|
263 | @from ||= (TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) - 1 | |
|
264 | @to ||= (TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) | |
|
263 | @from ||= (TimeEntry.earilest_date_for_project || Date.today) - 1 | |
|
264 | @to ||= (TimeEntry.latest_date_for_project || Date.today) | |
|
265 | 265 | end |
|
266 | 266 | |
|
267 | 267 | def load_available_criterias |
@@ -81,4 +81,12 class TimeEntry < ActiveRecord::Base | |||
|
81 | 81 | yield |
|
82 | 82 | end |
|
83 | 83 | end |
|
84 | ||
|
85 | def self.earilest_date_for_project | |
|
86 | TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) | |
|
87 | end | |
|
88 | ||
|
89 | def self.latest_date_for_project | |
|
90 | TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) | |
|
91 | end | |
|
84 | 92 | end |
@@ -48,4 +48,19 class TimeEntryTest < ActiveSupport::TestCase | |||
|
48 | 48 | def test_hours_should_default_to_nil |
|
49 | 49 | assert_nil TimeEntry.new.hours |
|
50 | 50 | end |
|
51 | ||
|
52 | context "#earilest_date_for_project" do | |
|
53 | should "return the lowest spent_on value that is visible to the current user" do | |
|
54 | User.current = nil | |
|
55 | assert_equal "2007-03-12", TimeEntry.earilest_date_for_project.to_s | |
|
56 | end | |
|
57 | end | |
|
58 | ||
|
59 | context "#latest_date_for_project" do | |
|
60 | should "return the highest spent_on value that is visible to the current user" do | |
|
61 | User.current = nil | |
|
62 | assert_equal "2007-04-22", TimeEntry.latest_date_for_project.to_s | |
|
63 | end | |
|
64 | end | |
|
65 | ||
|
51 | 66 | end |
General Comments 0
You need to be logged in to leave comments.
Login now