mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-23 17:26:11 +01:00
move daily test to daily pattern test
This commit is contained in:
parent
b84adfc172
commit
a9fa955c33
4 changed files with 53 additions and 32 deletions
|
|
@ -25,29 +25,6 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
@thursday = Time.zone.local(2008,6,12)
|
||||
end
|
||||
|
||||
def test_daily_every_day
|
||||
# every_day should return todays date if there was no previous date
|
||||
due_date = @every_day.get_due_date(nil)
|
||||
# use only day-month-year compare, because milisec / secs could be different
|
||||
assert_equal_dmy @today, due_date
|
||||
|
||||
# when the last todo was completed today, the next todo is due tomorrow
|
||||
due_date =@every_day.get_due_date(@today)
|
||||
assert_equal @tomorrow, due_date
|
||||
|
||||
# do something every 14 days
|
||||
@every_day.every_other1=14
|
||||
due_date = @every_day.get_due_date(@today)
|
||||
assert_equal @today+14.days, due_date
|
||||
end
|
||||
|
||||
def test_daily_work_days
|
||||
assert_equal @monday, @every_workday.get_due_date(@friday)
|
||||
assert_equal @monday, @every_workday.get_due_date(@saturday)
|
||||
assert_equal @monday, @every_workday.get_due_date(@sunday)
|
||||
assert_equal @tuesday, @every_workday.get_due_date(@monday)
|
||||
end
|
||||
|
||||
def test_show_from_date
|
||||
# assume that target due_date works fine, i.e. don't do the same tests over
|
||||
|
||||
|
|
@ -81,14 +58,6 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
# weekly/monthly/yearly
|
||||
end
|
||||
|
||||
def test_end_date_on_recurring_todo
|
||||
assert_equal true, @every_day.continues_recurring?(@in_three_days)
|
||||
assert_equal true, @every_day.continues_recurring?(@in_four_days)
|
||||
@every_day.end_date = @in_four_days
|
||||
@every_day.ends_on = 'ends_on_end_date'
|
||||
assert_equal false, @every_day.continues_recurring?(@in_four_days)
|
||||
end
|
||||
|
||||
def test_weekly_pattern
|
||||
assert_equal true, @weekly_every_day.continues_recurring?(nil)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ module RecurringTodos
|
|||
fixtures :users
|
||||
|
||||
def setup
|
||||
super
|
||||
@admin = users(:admin_user)
|
||||
end
|
||||
|
||||
|
|
@ -88,6 +89,16 @@ module RecurringTodos
|
|||
assert pattern.valid?, "should be valid"
|
||||
end
|
||||
|
||||
def test_end_date_on_recurring_todo
|
||||
rt = recurring_todos(:call_bill_gates_every_day)
|
||||
|
||||
assert_equal true, rt.continues_recurring?(@in_three_days)
|
||||
assert_equal true, rt.continues_recurring?(@in_four_days)
|
||||
rt.end_date = @in_four_days
|
||||
rt.ends_on = 'ends_on_end_date'
|
||||
assert_equal false, rt.continues_recurring?(@in_four_days)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_pattern(attributes)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ module RecurringTodos
|
|||
fixtures :users
|
||||
|
||||
def setup
|
||||
super
|
||||
@admin = users(:admin_user)
|
||||
@every_day = recurring_todos(:call_bill_gates_every_day)
|
||||
@every_workday = recurring_todos(:call_bill_gates_every_workday)
|
||||
end
|
||||
|
||||
def test_daily_attributes
|
||||
|
|
@ -43,6 +46,29 @@ module RecurringTodos
|
|||
assert_equal "every 2 days", @every_day.recurrence_pattern
|
||||
end
|
||||
|
||||
def test_daily_every_day
|
||||
# every_day should return todays date if there was no previous date
|
||||
due_date = @every_day.get_due_date(nil)
|
||||
# use only day-month-year compare, because milisec / secs could be different
|
||||
assert_equal_dmy @today, due_date
|
||||
|
||||
# when the last todo was completed today, the next todo is due tomorrow
|
||||
due_date =@every_day.get_due_date(@today)
|
||||
assert_equal @tomorrow, due_date
|
||||
|
||||
# do something every 14 days
|
||||
@every_day.every_other1=14
|
||||
due_date = @every_day.get_due_date(@today)
|
||||
assert_equal @today+14.days, due_date
|
||||
end
|
||||
|
||||
def test_daily_work_days
|
||||
assert_equal @monday, @every_workday.get_due_date(@friday)
|
||||
assert_equal @monday, @every_workday.get_due_date(@saturday)
|
||||
assert_equal @monday, @every_workday.get_due_date(@sunday)
|
||||
assert_equal @tuesday, @every_workday.get_due_date(@monday)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue