mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
REFACTOR: Remove Discourse.__container__
from tests
This commit is contained in:
@ -26,6 +26,7 @@ import { _clearSnapshots } from "select-kit/components/composer-actions";
|
||||
import User from "discourse/models/user";
|
||||
import { mapRoutes } from "discourse/mapping-router";
|
||||
import { currentSettings, mergeSettings } from "helpers/site-settings";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
|
||||
export function currentUser() {
|
||||
return User.create(sessionFixtures["/session/current.json"].current_user);
|
||||
@ -120,6 +121,7 @@ export function controllerModule(name, args = {}) {
|
||||
export function discourseModule(name, hooks) {
|
||||
QUnit.module(name, {
|
||||
beforeEach() {
|
||||
this.container = getOwner(this);
|
||||
this.siteSettings = currentSettings();
|
||||
if (hooks && hooks.beforeEach) {
|
||||
hooks.beforeEach.call(this);
|
||||
@ -148,10 +150,6 @@ export function acceptance(name, options) {
|
||||
HeaderComponent.reopen({ examineDockHeader: function() {} });
|
||||
|
||||
resetExtraClasses();
|
||||
if (options.beforeEach) {
|
||||
options.beforeEach.call(this);
|
||||
}
|
||||
|
||||
if (options.mobileView) {
|
||||
forceMobile();
|
||||
}
|
||||
@ -173,6 +171,10 @@ export function acceptance(name, options) {
|
||||
clearHTMLCache();
|
||||
resetPluginApi();
|
||||
Discourse.reset();
|
||||
this.container = getOwner(this);
|
||||
if (options.beforeEach) {
|
||||
options.beforeEach.call(this);
|
||||
}
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
@ -197,14 +199,14 @@ export function acceptance(name, options) {
|
||||
resetOneboxCache();
|
||||
resetCustomPostMessageCallbacks();
|
||||
_clearSnapshots();
|
||||
Discourse._runInitializer("instanceInitializers", function(
|
||||
initName,
|
||||
initializer
|
||||
) {
|
||||
if (initializer && initializer.teardown) {
|
||||
initializer.teardown(Discourse.__container__);
|
||||
Discourse._runInitializer(
|
||||
"instanceInitializers",
|
||||
(initName, initializer) => {
|
||||
if (initializer && initializer.teardown) {
|
||||
initializer.teardown(this.container);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
Discourse.reset();
|
||||
|
||||
// We do this after reset so that the willClearRender will have already fired
|
||||
@ -214,7 +216,7 @@ export function acceptance(name, options) {
|
||||
}
|
||||
|
||||
export function controllerFor(controller, model) {
|
||||
controller = Discourse.__container__.lookup("controller:" + controller);
|
||||
controller = getOwner(this).lookup("controller:" + controller);
|
||||
if (model) {
|
||||
controller.set("model", model);
|
||||
}
|
||||
|
Reference in New Issue
Block a user