mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 08:51:05 +08:00
Remove Discourse.SiteSettings
from tests (#10193)
* Remove unused Discourse.SiteSettings * Remove `Discourse.SiteSettings` from many tests * REFACTOR: `lib:formatter` was using a lot of leaky state * Remove more `Discourse.SiteSettings` from tests * More SiteSettings removed from tests
This commit is contained in:
@ -24,6 +24,7 @@ import { resetCache as resetOneboxCache } from "pretty-text/oneboxer";
|
||||
import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
|
||||
import { _clearSnapshots } from "select-kit/components/composer-actions";
|
||||
import User from "discourse/models/user";
|
||||
import { mapRoutes } from "discourse/mapping-router";
|
||||
|
||||
export function currentUser() {
|
||||
return User.create(sessionFixtures["/session/current.json"].current_user);
|
||||
@ -101,6 +102,37 @@ export function applyPretender(name, server, helper) {
|
||||
if (cb) cb(server, helper);
|
||||
}
|
||||
|
||||
export function controllerModule(name, args = {}) {
|
||||
moduleFor(name, name, {
|
||||
setup() {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
let controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
if (args.setupController) {
|
||||
args.setupController(controller);
|
||||
}
|
||||
},
|
||||
needs: args.needs
|
||||
});
|
||||
}
|
||||
|
||||
export function discourseModule(name, hooks) {
|
||||
QUnit.module(name, {
|
||||
beforeEach() {
|
||||
// Give us an API to change site settings without `Discourse.SiteSettings` in tests
|
||||
this.siteSettings = Discourse.SiteSettings;
|
||||
if (hooks && hooks.beforeEach) {
|
||||
hooks.beforeEach.call(this);
|
||||
}
|
||||
},
|
||||
afterEach() {
|
||||
if (hooks && hooks.afterEach) {
|
||||
hooks.afterEach.call(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function acceptance(name, options) {
|
||||
options = options || {};
|
||||
|
||||
@ -135,6 +167,7 @@ export function acceptance(name, options) {
|
||||
options.settings
|
||||
);
|
||||
}
|
||||
this.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
if (options.site) {
|
||||
resetSite(Discourse.SiteSettings, options.site);
|
||||
|
Reference in New Issue
Block a user