feat(store): add recur and recur_mode task fields
Problem: the task schema has no fields for storing recurrence rules. Solution: add recur and recur_mode to the Task class, known_fields, task_to_table, table_to_task, and the add() signature.
This commit is contained in:
parent
c2310f2659
commit
e69e93f536
2 changed files with 50 additions and 1 deletions
|
|
@ -196,6 +196,41 @@ describe('store', function()
|
|||
end)
|
||||
end)
|
||||
|
||||
describe('recurrence fields', function()
|
||||
it('persists recur and recur_mode through round-trip', function()
|
||||
store.load()
|
||||
store.add({ description = 'Recurring', recur = 'weekly', recur_mode = 'scheduled' })
|
||||
store.save()
|
||||
store.unload()
|
||||
store.load()
|
||||
local task = store.get(1)
|
||||
assert.are.equal('weekly', task.recur)
|
||||
assert.are.equal('scheduled', task.recur_mode)
|
||||
end)
|
||||
|
||||
it('persists recur without recur_mode', function()
|
||||
store.load()
|
||||
store.add({ description = 'Simple recur', recur = 'daily' })
|
||||
store.save()
|
||||
store.unload()
|
||||
store.load()
|
||||
local task = store.get(1)
|
||||
assert.are.equal('daily', task.recur)
|
||||
assert.is_nil(task.recur_mode)
|
||||
end)
|
||||
|
||||
it('omits recur fields when not set', function()
|
||||
store.load()
|
||||
store.add({ description = 'No recur' })
|
||||
store.save()
|
||||
store.unload()
|
||||
store.load()
|
||||
local task = store.get(1)
|
||||
assert.is_nil(task.recur)
|
||||
assert.is_nil(task.recur_mode)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('active_tasks', function()
|
||||
it('excludes deleted tasks', function()
|
||||
store.load()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue