Skip to content

Commit

Permalink
Merge pull request #6427 from grzesiek2010/COLLECT-6285
Browse files Browse the repository at this point in the history
Fixed removing savepoints on finalize
  • Loading branch information
grzesiek2010 authored Sep 24, 2024
2 parents 989ae30 + 1c35f25 commit 2d8bafd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,16 @@ public void instanceOfEncryptedFormWithoutInstanceID_failsFinalizationWithMessag
.clickDrafts()
.checkInstanceState("encrypted-no-instanceID", Instance.STATUS_INCOMPLETE);
}

@Test
public void instanceOfEncryptedFormWithoutInstanceID_doesNotLeaveSavepointOnFinalization() {
rule.startAtMainMenu()
.copyForm("encrypted-no-instanceID.xml")
.startBlankForm("encrypted-no-instanceID")
.clickGoToArrow()
.clickGoToEnd()
.clickFinalize()
.checkIsToastWithMessageDisplayed("This form does not specify an instanceID. You must specify one to enable encryption. Form has not been saved as finalized.")
.startBlankForm("encrypted-no-instanceID");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.odk.collect.android.tasks.SaveFormToDisk.SAVED;
import static org.odk.collect.android.tasks.SaveFormToDisk.SAVED_AND_EXIT;
import static org.odk.collect.android.tasks.SaveFormToDisk.SAVE_ERROR;
import static org.odk.collect.shared.strings.StringUtils.isBlank;

import android.net.Uri;
Expand Down Expand Up @@ -256,7 +257,7 @@ private void handleTaskResult(SaveToDiskResult taskResult, SaveRequest saveReque
return;
}

if (taskResult.getSaveResult() == SAVED || taskResult.getSaveResult() == SAVED_AND_EXIT) {
if (taskResult.getSaveResult() != SAVE_ERROR) {
removeSavepoint(form.getDbId(), instance != null ? instance.getDbId() : null);
}

Expand Down Expand Up @@ -284,7 +285,7 @@ private void handleTaskResult(SaveToDiskResult taskResult, SaveRequest saveReque
break;
}

case SaveFormToDisk.SAVE_ERROR: {
case SAVE_ERROR: {
formController.getAuditEventLogger().logEvent(AuditEvent.AuditEventType.SAVE_ERROR, true, clock.get());
saveResult.setValue(new SaveResult(SaveResult.State.SAVE_ERROR, saveRequest, taskResult.getSaveErrorMessage()));
break;
Expand Down

0 comments on commit 2d8bafd

Please sign in to comment.