mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +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
|
||||
|
|
@ -13,7 +13,22 @@ class ActiveSupport::TestCase
|
|||
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
||||
# -- they do not yet inherit this setting
|
||||
fixtures :all
|
||||
|
||||
|
||||
def setup
|
||||
@today = Time.now.utc
|
||||
@tomorrow = @today + 1.day
|
||||
@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)
|
||||
end
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
def assert_value_changed(object, method = nil)
|
||||
initial_value = object.send(method)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue