mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
improve test of daily repeat pattern
This commit is contained in:
parent
a9fa955c33
commit
0c153ef28c
3 changed files with 17 additions and 8 deletions
|
|
@ -18,7 +18,7 @@ module RecurringTodos
|
|||
if only_work_days?
|
||||
I18n.t("todos.recurrence.pattern.on_work_days")
|
||||
elsif every_x_days > 1
|
||||
I18n.t("todos.recurrence.pattern.every_n", :n => every_x_days) + " " + I18n.t("common.days_midsentence.other")
|
||||
I18n.t("todos.recurrence.pattern.every_n_days", :n => every_x_days)
|
||||
else
|
||||
I18n.t("todos.recurrence.pattern.every_day")
|
||||
end
|
||||
|
|
@ -37,10 +37,11 @@ module RecurringTodos
|
|||
start = determine_start(previous, 1.day)
|
||||
|
||||
if only_work_days?
|
||||
# jump over weekend if necessary
|
||||
return start + 2.day if start.wday() == 6 # saturday
|
||||
return start + 1.day if start.wday() == 0 # sunday
|
||||
return start
|
||||
else # every nth day; n = every_other1
|
||||
else
|
||||
# if there was no previous todo, do not add n: the first todo starts on
|
||||
# today or on start_from
|
||||
return previous == nil ? start : start+every_x_days.day-1.day
|
||||
|
|
|
|||
|
|
@ -623,13 +623,14 @@ en:
|
|||
- December
|
||||
third: third
|
||||
every_n: every %{n}
|
||||
every_n_days: every %{n} days
|
||||
every_day: every day
|
||||
on_day_n: on day %{n}
|
||||
second: second
|
||||
every_xth_day_of_every_n_months: every %{x} %{day} of every %{n_months}
|
||||
from: from
|
||||
weekly: weekly
|
||||
last: last
|
||||
every_day: every day
|
||||
the_xth_day_of_month: the %{x} %{day} of %{month}
|
||||
times: for %{number} times
|
||||
on_work_days: on work days
|
||||
|
|
|
|||
|
|
@ -62,11 +62,18 @@ module RecurringTodos
|
|||
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)
|
||||
def test_only_work_days_skips_weekend
|
||||
assert_equal @tuesday, @every_workday.get_due_date(@monday), "should select next day if it is not in weekend"
|
||||
|
||||
assert_equal @monday, @every_workday.get_due_date(@friday), "should select monday if it is in weekend"
|
||||
assert_equal @monday, @every_workday.get_due_date(@saturday), "should select monday if it is in weekend"
|
||||
assert_equal @monday, @every_workday.get_due_date(@sunday), "should select monday if it is in weekend"
|
||||
end
|
||||
|
||||
def test_every_x_days
|
||||
assert_equal @tuesday, @every_day.get_due_date(@monday), "should select next day in middle week"
|
||||
assert_equal @saturday, @every_day.get_due_date(@friday), "should select next day at end of week"
|
||||
assert_equal @sunday, @every_day.get_due_date(@saturday), "should select next day in weekend"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue