mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
fix case where future start_from was ignored for yearly recurrence patterns
This commit is contained in:
parent
666f524b16
commit
f4378ffde1
2 changed files with 14 additions and 1 deletions
|
|
@ -508,7 +508,13 @@ class RecurringTodo < ActiveRecord::Base
|
|||
if previous.nil?
|
||||
start = self.start_from.nil? ? Time.now.utc : self.start_from
|
||||
else
|
||||
start = previous
|
||||
if self.start_from.nil?
|
||||
start = previous
|
||||
else
|
||||
# check if the start_from date is later than previous. If so, use
|
||||
# start_from as start to search for next date
|
||||
start = self.start_from > previous ? self.start_from : previous
|
||||
end
|
||||
end
|
||||
|
||||
day = self.every_other1
|
||||
|
|
|
|||
|
|
@ -203,6 +203,13 @@ class RecurringTodoTest < Test::Rails::TestCase
|
|||
due_date1 = @yearly.get_due_date(nil)
|
||||
due_date2 = @yearly.get_due_date(Time.now.utc + 1.day)
|
||||
assert_equal due_date1, due_date2
|
||||
end
|
||||
|
||||
def test_start_from_in_future
|
||||
# start from after june 8th 2008
|
||||
@yearly.start_from = Time.utc(2008,6,12)
|
||||
assert_equal Time.utc(2009,6,8), @yearly.get_due_date(nil) # jun 8th next year
|
||||
assert_equal Time.utc(2009,6,8), @yearly.get_due_date(Time.utc(2008,6,1)) # also next year
|
||||
|
||||
this_year = Time.now.utc.year
|
||||
@yearly.start_from = Time.utc(this_year+1,6,12)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue