Address review of repeat from completion (#79)
This commit is contained in:
1 parent
70df9c8a4d
commit
b0885169e7
11 files changed
+175
-61
No files matched your search
+57
@@ -297,6 +297,63 @@ class RoomTasksDataSourceTest {
|
||||
assertThat(copy.title).isEqualTo("Water the plants")
|
||||
}
|
||||
|
||||
private fun fromCompletion(at: Instant, rule: String): Long = source.insertTask(
|
||||
TaskForm(title = "Water the plants", listId = listId, start = at, due = at + 1.hours, rrule = rule, repeatFromCompletion = true),
|
||||
)
|
||||
|
||||
@Test
|
||||
fun aLateTickOfAFromCompletionSeriesCountsFromToday() {
|
||||
val at = now - 10.days
|
||||
val id = fromCompletion(at, "FREQ=DAILY;INTERVAL=7;COUNT=5")
|
||||
|
||||
source.setCompletedInstance(id, at, completed = true)
|
||||
|
||||
val master = db.tasks().entity(id)!!
|
||||
assertThat(master.dtstart!!).isGreaterThan(now)
|
||||
assertThat(master.dtstart!!).isLessThan(now + 8.days)
|
||||
assertThat(master.due).isEqualTo(master.dtstart!! + 1.hours)
|
||||
assertThat(master.rrule).isEqualTo("FREQ=DAILY;INTERVAL=7;COUNT=4")
|
||||
assertThat(master.repeatsFromCompletion).isTrue()
|
||||
val copy = db.tasks().allIn(listId).single { it.id != id }
|
||||
assertThat(copy.status).isEqualTo(TaskStatus.COMPLETED)
|
||||
assertThat(copy.dtstart).isEqualTo(at)
|
||||
assertThat(copy.repeatsFromCompletion).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anEarlyTickOfAFromCompletionSeriesStillMovesItOn() {
|
||||
val at = now + 1.days
|
||||
val id = fromCompletion(at, "FREQ=DAILY")
|
||||
|
||||
source.setCompletedInstance(id, at, completed = true)
|
||||
|
||||
assertThat(db.tasks().entity(id)!!.dtstart!!).isGreaterThan(at)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun reopeningAFromCompletionTickMovesTheSeriesBack() {
|
||||
val at = now - 10.days
|
||||
val id = fromCompletion(at, "FREQ=DAILY;INTERVAL=7;COUNT=5")
|
||||
source.setCompletedInstance(id, at, completed = true)
|
||||
|
||||
source.setCompletedInstance(id, at, completed = false)
|
||||
|
||||
val master = db.tasks().entity(id)!!
|
||||
assertThat(master.dtstart).isEqualTo(at)
|
||||
assertThat(master.rrule).isEqualTo("FREQ=DAILY;INTERVAL=7;COUNT=5")
|
||||
assertThat(db.tasks().allIn(listId).filter { !it.isDeleted }.map { it.id }).containsExactly(id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theLastTickOfAFromCompletionSeriesClosesIt() {
|
||||
val at = now - 1.days
|
||||
val id = fromCompletion(at, "FREQ=DAILY;COUNT=1")
|
||||
|
||||
source.setCompletedInstance(id, at, completed = true)
|
||||
|
||||
assertThat(db.tasks().entity(id)!!.status).isEqualTo(TaskStatus.COMPLETED)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun reopeningTheOccurrenceMovesTheSeriesBack() {
|
||||
val at = now
|
||||
|
||||
Reference in new issue
Block a user