Skip to content

A platform for community discussion. Free, open, simple.

DEV: avoid sending events to a destroying object and enable few skipped tests (#15030)

Andrei Prigorshnevf37375f58281
diff --git a/app/assets/javascripts/discourse/app/controllers/flag.js b/app/assets/javascripts/discourse/app/controllers/flag.js
index 042bea17de1..49ea8b525d1 100644
--- a/app/assets/javascripts/discourse/app/controllers/flag.js
+++ b/app/assets/javascripts/discourse/app/controllers/flag.js
@@ -275,6 +275,10 @@ export default Controller.extend(ModalFunctionality, {
postAction
.act(this.model, params)
.then(() => {
+ if (this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
if (!params.skipClose) {
this.send("closeModal");
}
@@ -286,7 +290,9 @@ export default Controller.extend(ModalFunctionality, {
});
})
.catch((error) => {
- this.send("closeModal");
+ if (!this.isDestroying && !this.isDestroyed) {
+ this.send("closeModal");
+ }
popupAjaxError(error);
});
},
diff --git a/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js b/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js
index ded890b5dde..587fd4473c8 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js
@@ -6,7 +6,7 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
-import { skip, test } from "qunit";
+import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { run } from "@ember/runloop";
@@ -153,7 +153,7 @@ acceptance("flagging", function (needs) {
assert.ok(!exists(".bootbox.modal:visible"));
});
- skip("CTRL + ENTER accepts the modal", async function (assert) {
+ test("CTRL + ENTER accepts the modal", async function (assert) {
await visit("/t/internationalization-localization/280");
await openFlagModal();
@@ -169,7 +169,7 @@ acceptance("flagging", function (needs) {
assert.ok(!exists("#discourse-modal:visible"), "The modal was closed");
});
- skip("CMD or WINDOWS-KEY + ENTER accepts the modal", async function (assert) {
+ test("CMD or WINDOWS-KEY + ENTER accepts the modal", async function (assert) {
await visit("/t/internationalization-localization/280");
await openFlagModal();