mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 17:28:50 +01:00
move tests from recurring_todo_test to respective repeat_pattern_tests
This commit is contained in:
parent
0c153ef28c
commit
3cb18cd875
7 changed files with 163 additions and 130 deletions
|
|
@ -58,95 +58,6 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
# weekly/monthly/yearly
|
||||
end
|
||||
|
||||
def test_weekly_pattern
|
||||
assert_equal true, @weekly_every_day.continues_recurring?(nil)
|
||||
|
||||
due_date = @weekly_every_day.get_due_date(@sunday)
|
||||
assert_equal @monday, due_date
|
||||
|
||||
# saturday is last day in week, so the next date should be sunday + n-1 weeks
|
||||
# n-1 because sunday is already in the next week
|
||||
@weekly_every_day.every_other1 = 3
|
||||
due_date = @weekly_every_day.get_due_date(@saturday)
|
||||
assert_equal @sunday + 2.weeks, due_date
|
||||
|
||||
# remove tuesday and wednesday
|
||||
@weekly_every_day.every_day = 'sm tfs'
|
||||
due_date = @weekly_every_day.get_due_date(@monday)
|
||||
assert_equal @thursday, due_date
|
||||
|
||||
@weekly_every_day.every_other1 = 1
|
||||
@weekly_every_day.every_day = ' tw '
|
||||
due_date = @weekly_every_day.get_due_date(@tuesday)
|
||||
assert_equal @wednesday, due_date
|
||||
due_date = @weekly_every_day.get_due_date(@wednesday)
|
||||
assert_equal @tuesday+1.week, due_date
|
||||
|
||||
@weekly_every_day.every_day = ' s'
|
||||
due_date = @weekly_every_day.get_due_date(@sunday)
|
||||
assert_equal @saturday+1.week, due_date
|
||||
end
|
||||
|
||||
def test_monthly_pattern
|
||||
due_date = @monthly_every_last_friday.get_due_date(@sunday)
|
||||
assert_equal Time.zone.local(2008,6,27), due_date
|
||||
|
||||
friday_is_last_day_of_month = Time.zone.local(2008,10,31)
|
||||
due_date = @monthly_every_last_friday.get_due_date(friday_is_last_day_of_month-1.day )
|
||||
assert_equal friday_is_last_day_of_month , due_date
|
||||
|
||||
@monthly_every_third_friday = @monthly_every_last_friday
|
||||
@monthly_every_third_friday.every_other3=3 #third
|
||||
due_date = @monthly_every_last_friday.get_due_date(@sunday) # june 8th 2008
|
||||
assert_equal Time.zone.local(2008, 6, 20), due_date
|
||||
# set date past third friday of this month
|
||||
due_date = @monthly_every_last_friday.get_due_date(Time.zone.local(2008,6,21)) # june 21th 2008
|
||||
assert_equal Time.zone.local(2008, 8, 15), due_date # every 2 months, so aug
|
||||
|
||||
@monthly = @monthly_every_last_friday
|
||||
@monthly.recurrence_selector=0
|
||||
@monthly.every_other1 = 8 # every 8th day of the month
|
||||
@monthly.every_other2 = 2 # every 2 months
|
||||
|
||||
due_date = @monthly.get_due_date(@saturday) # june 7th
|
||||
assert_equal @sunday, due_date # june 8th
|
||||
|
||||
due_date = @monthly.get_due_date(@sunday) # june 8th
|
||||
assert_equal Time.zone.local(2008,8,8), due_date # aug 8th
|
||||
end
|
||||
|
||||
def test_yearly_pattern
|
||||
# beginning of same year
|
||||
due_date = @yearly.get_due_date(Time.zone.local(2008,2,10)) # feb 10th
|
||||
assert_equal @sunday, due_date # june 8th
|
||||
|
||||
# same month, previous date
|
||||
due_date = @yearly.get_due_date(@saturday) # june 7th
|
||||
show_from_date = @yearly.get_show_from_date(@saturday) # june 7th
|
||||
assert_equal @sunday, due_date # june 8th
|
||||
assert_equal @sunday-5.days, show_from_date
|
||||
|
||||
# same month, day after
|
||||
due_date = @yearly.get_due_date(@monday) # june 9th
|
||||
assert_equal Time.zone.local(2009,6,8), due_date # june 8th next year
|
||||
# very overdue
|
||||
due_date = @yearly.get_due_date(@monday+5.months-2.days) # november 7
|
||||
assert_equal Time.zone.local(2009,6,8), due_date # june 8th next year
|
||||
|
||||
@yearly.recurrence_selector = 1
|
||||
@yearly.every_other3 = 2 # second
|
||||
@yearly.every_count = 3 # wednesday
|
||||
# beginning of same year
|
||||
due_date = @yearly.get_due_date(Time.zone.local(2008,2,10)) # feb 10th
|
||||
assert_equal Time.zone.local(2008,6,11), due_date # june 11th
|
||||
# same month, before second wednesday
|
||||
due_date = @yearly.get_due_date(@saturday) # june 7th
|
||||
assert_equal Time.zone.local(2008,6,11), due_date # june 11th
|
||||
# same month, after second wednesday
|
||||
due_date = @yearly.get_due_date(Time.zone.local(2008,6,12)) # june 7th
|
||||
assert_equal Time.zone.local(2009,6,10), due_date # june 10th
|
||||
end
|
||||
|
||||
def test_next_todo_without_previous_todo
|
||||
# test handling of nil as previous
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue