Skip to content
Browse files

Fix unit test with reminders

  • Loading branch information...
1 parent ca4e9c7 commit 7d6bcee9b04dd8eaaf2d44d08ad968877d394d8a @timsu timsu committed May 19, 2011
View
13 astrid/src/com/todoroo/astrid/dao/TaskDao.java
@@ -222,15 +222,12 @@ public boolean saveExisting(Task item) {
/**
* Called after the task is saved. This differs from the call in
* TaskApiDao in that it runs hooks that need to be run from within
- * Astrid.
+ * Astrid. Order matters here!
*/
public static void afterSave(Task task, ContentValues values) {
- if(TaskApiDao.insignificantChange(values))
+ if(values == null)
return;
- // run global save hooks
- TaskApiDao.afterSave(task, values);
-
if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted())
afterComplete(task, values);
else {
@@ -242,6 +239,12 @@ public static void afterSave(Task task, ContentValues values) {
ReminderService.getInstance().scheduleAlarm(task);
}
+ if(TaskApiDao.insignificantChange(values))
+ return;
+
+ // run api save hooks
+ TaskApiDao.afterSave(task, values);
+
for(DatabaseUpdateListener listener : taskChangeListeners) {
listener.onDatabaseUpdated();
}
View
4 tests/src/com/todoroo/astrid/repeats/AdvancedRepeatTests.java
@@ -27,9 +27,9 @@ public void testDueDateInPast() throws ParseException {
// repeat once => due date should become tomorrow
long past = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, new Date(110, 7, 1).getTime());
task.setValue(Task.DUE_DATE, past);
- long today = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, DateUtilities.now());
+ long tomorrow = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, DateUtilities.now() + DateUtilities.ONE_DAY);
long nextDueDate = RepeatTaskCompleteListener.computeNextDueDate(task, rrule.toIcal());
- assertDatesEqual(today, nextDueDate);
+ assertDatesEqual(tomorrow, nextDueDate);
// test specific day & time
long pastWithTime = task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, new Date(110, 7, 1, 10, 4).getTime());

0 comments on commit 7d6bcee

Please sign in to comment.
Something went wrong with that request. Please try again.