Skip to content

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

DEV: Deprecate `controllerFor` test helper (#19606)

Jarek Radosz953b823c5a13
diff --git a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js
index 79f31319c4e..91fc61547b1 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js
@@ -1,6 +1,5 @@
import {
acceptance,
- controllerFor,
count,
exists,
query,
@@ -11,6 +10,7 @@ import I18n from "I18n";
import { hbs } from "ember-cli-htmlbars";
import showModal from "discourse/lib/show-modal";
import { registerTemporaryModule } from "../helpers/temporary-module-helper";
+import { getOwner } from "discourse-common/lib/get-owner";
acceptance("Modal", function (needs) {
let _translations;
@@ -38,7 +38,7 @@ acceptance("Modal", function (needs) {
await click(".login-button");
assert.strictEqual(count(".d-modal:visible"), 1, "modal should appear");
- let controller = controllerFor("modal");
+ const controller = getOwner(this).lookup("controller:modal");
assert.strictEqual(controller.name, "login");
await click(".modal-outer-container");
diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
index b4d49f2f6dc..79d7b6453ef 100644
--- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
@@ -397,6 +397,14 @@ export function acceptance(name, optionsOrCallback) {
}
export function controllerFor(controller, model) {
+ deprecated(
+ 'controllerFor is deprecated. Use the standard `getOwner(this).lookup("controller:NAME")` instead',
+ {
+ id: "controller-for",
+ since: "3.0.0.beta14",
+ }
+ );
+
controller = getOwner(this).lookup("controller:" + controller);
if (model) {
controller.set("model", model);
@@ -412,7 +420,7 @@ export function fixture(selector) {
}
QUnit.assert.not = function (actual, message) {
- deprecated("assert.not() is deprecated. Use assert.notOk() instead.", {
+ deprecated("assert.not() is deprecated. Use assert.false() instead.", {
since: "2.9.0.beta1",
dropFrom: "2.10.0.beta1",
id: "discourse.qunit.assert-not",