@@ -260,8 +260,8 private | |||||
260 | end |
|
260 | end | |
261 |
|
261 | |||
262 | @from, @to = @to, @from if @from && @to && @from > @to |
|
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 |
|
263 | @from ||= (TimeEntry.earilest_date_for_project || Date.today) - 1 | |
264 | @to ||= (TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) |
|
264 | @to ||= (TimeEntry.latest_date_for_project || Date.today) | |
265 | end |
|
265 | end | |
266 |
|
266 | |||
267 | def load_available_criterias |
|
267 | def load_available_criterias |
@@ -81,4 +81,12 class TimeEntry < ActiveRecord::Base | |||||
81 | yield |
|
81 | yield | |
82 | end |
|
82 | end | |
83 | end |
|
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 | end |
|
92 | end |
@@ -48,4 +48,19 class TimeEntryTest < ActiveSupport::TestCase | |||||
48 | def test_hours_should_default_to_nil |
|
48 | def test_hours_should_default_to_nil | |
49 | assert_nil TimeEntry.new.hours |
|
49 | assert_nil TimeEntry.new.hours | |
50 | end |
|
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 | end |
|
66 | end |
General Comments 0
You need to be logged in to leave comments.
Login now