DEV: Fix tests.

DEV: Fix tests.

diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
index 3eea5c7..2bf1dcd 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
@@ -21,7 +21,8 @@ import {
   getEncryptionStatus,
   PACKED_KEY_FOOTER,
   PACKED_KEY_HEADER,
-  PACKED_KEY_SEPARATOR
+  PACKED_KEY_SEPARATOR,
+  reload
 } from "discourse/plugins/discourse-encrypt/lib/discourse";
 
 // TODO: I believe this should get into core.
@@ -241,7 +242,7 @@ export default {
             key: ""
           });
 
-          window.location.reload();
+          reload();
         })
 
         .catch(popupAjaxError);
@@ -276,7 +277,7 @@ export default {
           this.send("hidePassphraseInput");
           this.set("inProgress", false);
 
-          window.location.reload();
+          reload();
         })
 
         .catch(() => {
@@ -339,7 +340,7 @@ export default {
       deleteIndexedDb().then(() => {
         this.appEvents.trigger("encrypt:status-changed");
         this.set("inProgress", false);
-        window.location.reload();
+        reload();
       });
     },
 
diff --git a/assets/javascripts/lib/discourse.js.es6 b/assets/javascripts/lib/discourse.js.es6
index 0b5118d..554b5db 100644
--- a/assets/javascripts/lib/discourse.js.es6
+++ b/assets/javascripts/lib/discourse.js.es6
@@ -192,3 +192,14 @@ export function getEncryptionStatus(user) {
 
   return ENCRYPT_ACTIVE;
 }
+
+/**
+ * Reloads current page.
+ *
+ * This function is usually called when status change so all initializers
+ * checks can run again.
+ */
+export function reload() {
+  console.log("Reloading...");
+  window.location.reload();
+}
diff --git a/test/javascripts/acceptance/encrypt-test.js.es6 b/test/javascripts/acceptance/encrypt-test.js.es6
index f7aa4ad..c6e8957 100644
--- a/test/javascripts/acceptance/encrypt-test.js.es6
+++ b/test/javascripts/acceptance/encrypt-test.js.es6
@@ -16,6 +16,7 @@ import {
   ENCRYPT_ENABLED,
   ENCRYPT_ACTIVE
 } from "discourse/plugins/discourse-encrypt/lib/discourse";
+import * as DiscourseEncryptLib from "discourse/plugins/discourse-encrypt/lib/discourse";
 import { default as userFixtures } from "fixtures/user_fixtures";
 import { parsePostData } from "helpers/create-pretender";
 
@@ -129,6 +130,8 @@ acceptance("Encrypt", {
   settings: { encrypt_enabled: true, encrypt_groups: "" },
 
   beforeEach() {
+    sandbox.stub(DiscourseEncryptLib, "reload");
+
     // Hook `XMLHttpRequest` to search for leaked plaintext.
     XMLHttpRequest.prototype.send_ = XMLHttpRequest.prototype.send;
     XMLHttpRequest.prototype.send = function(body) {

GitHub sha: 1693ffe0