mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
parent
42961e9701
commit
cd09cce7a4
2 changed files with 26 additions and 13 deletions
|
|
@ -127,7 +127,7 @@ module RecurringTodos
|
|||
def get_due_date(previous)
|
||||
case target
|
||||
when 'due_date'
|
||||
get_next_date(previous)
|
||||
get_next_date(previous).at_midnight
|
||||
when 'show_from_date'
|
||||
nil
|
||||
end
|
||||
|
|
@ -141,7 +141,7 @@ module RecurringTodos
|
|||
get_due_date(previous) - show_from_delta.days
|
||||
when 'show_from_date'
|
||||
# Leave due date empty
|
||||
get_next_date(previous)
|
||||
get_next_date(previous).at_midnight
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
@in_three_days = @today + 3.days
|
||||
@in_four_days = @in_three_days + 1.day # need a day after start_from
|
||||
|
||||
@friday = Time.zone.local(2008,6,6)
|
||||
@saturday = Time.zone.local(2008,6,7)
|
||||
@sunday = Time.zone.local(2008,6,8) # june 8, 2008 was a sunday
|
||||
@monday = Time.zone.local(2008,6,9)
|
||||
@tuesday = Time.zone.local(2008,6,10)
|
||||
@wednesday = Time.zone.local(2008,6,11)
|
||||
@thursday = Time.zone.local(2008,6,12)
|
||||
@friday = Time.zone.local(2008,6,6,1,2,3)
|
||||
@saturday = Time.zone.local(2008,6,7,1,2,3)
|
||||
@sunday = Time.zone.local(2008,6,8,1,2,3) # june 8, 2008 was a sunday
|
||||
@monday = Time.zone.local(2008,6,9,1,2,3)
|
||||
@tuesday = Time.zone.local(2008,6,10,1,2,3)
|
||||
@wednesday = Time.zone.local(2008,6,11,1,2,3)
|
||||
@thursday = Time.zone.local(2008,6,12,1,2,3)
|
||||
end
|
||||
|
||||
def test_show_from_date
|
||||
|
|
@ -35,7 +35,7 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
|
||||
# check show from get the next day
|
||||
assert_equal_dmy @today, @every_day.get_show_from_date(@today-1.days)
|
||||
assert_equal @today+1.day, @every_day.get_show_from_date(@today)
|
||||
assert_equal (@today+1.day).at_midnight, @every_day.get_show_from_date(@today)
|
||||
|
||||
@every_day.target='due_date'
|
||||
# when target on due_date, show_from is relative to due date unless show_always is true
|
||||
|
|
@ -58,6 +58,19 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
# weekly/monthly/yearly
|
||||
end
|
||||
|
||||
def test_show_from_at_midnight
|
||||
test_cases = [@every_day, @every_workday, @weekly_every_day, @every_week, @monthly_every_last_friday, @yearly]
|
||||
test_cases.each do |test_case|
|
||||
test_case.target='show_from_date'
|
||||
show_from_date = test_case.get_show_from_date(@today)
|
||||
assert_equal show_from_date.at_midnight, show_from_date unless show_from_date.nil?
|
||||
|
||||
test_case.target='due_date'
|
||||
show_from_date = test_case.get_show_from_date(@today)
|
||||
assert_equal show_from_date.at_midnight, show_from_date unless show_from_date.nil?
|
||||
end
|
||||
end
|
||||
|
||||
def test_next_todo_without_previous_todo
|
||||
# test handling of nil as previous
|
||||
#
|
||||
|
|
@ -92,14 +105,14 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
# every_day should return start_day if it is in the future
|
||||
@every_day.start_from = @in_three_days
|
||||
due_date = @every_day.get_due_date(nil)
|
||||
assert_equal @in_three_days.to_s(:db), due_date.to_s(:db)
|
||||
assert_equal @in_three_days.at_midnight.to_s(:db), due_date.to_s(:db)
|
||||
due_date = @every_day.get_due_date(@tomorrow)
|
||||
assert_equal @in_three_days, due_date
|
||||
assert_equal @in_three_days.at_midnight, due_date
|
||||
|
||||
# if we give a date in the future for the previous todo, the next to do
|
||||
# should be based on that future date.
|
||||
due_date = @every_day.get_due_date(@in_four_days)
|
||||
assert_equal @in_four_days+1.day, due_date
|
||||
assert_equal (@in_four_days+1.day).at_midnight, due_date
|
||||
|
||||
@weekly_every_day.start_from = Time.zone.local(2020,1,1)
|
||||
assert_equal Time.zone.local(2020,1,1), @weekly_every_day.get_due_date(nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue