mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 03:02:46 +08:00
DEV: Fix some more deprecated Discourse.User and Discourse.Site
This commit is contained in:
parent
4843414de6
commit
3d0b310368
|
@ -1,3 +1,5 @@
|
|||
import User from "discourse/models/user";
|
||||
|
||||
export function parsePostData(query) {
|
||||
const result = {};
|
||||
query.split("&").forEach(function(part) {
|
||||
|
@ -29,7 +31,7 @@ export function success() {
|
|||
return response({ success: true });
|
||||
}
|
||||
|
||||
const loggedIn = () => !!Discourse.User.current();
|
||||
const loggedIn = () => !!User.current();
|
||||
const helpers = { response, success, parsePostData };
|
||||
export let fixturesByUrl;
|
||||
|
||||
|
|
|
@ -20,20 +20,19 @@ import { resetWidgetCleanCallbacks } from "discourse/components/mount-widget";
|
|||
import { resetDecorators as resetPostCookedDecorators } from "discourse/widgets/post-cooked";
|
||||
import { resetCache as resetOneboxCache } from "pretty-text/oneboxer";
|
||||
import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
export function currentUser() {
|
||||
return Discourse.User.create(
|
||||
sessionFixtures["/session/current.json"].current_user
|
||||
);
|
||||
return User.create(sessionFixtures["/session/current.json"].current_user);
|
||||
}
|
||||
|
||||
export function updateCurrentUser(properties) {
|
||||
Discourse.User.current().setProperties(properties);
|
||||
User.current().setProperties(properties);
|
||||
}
|
||||
|
||||
// Note: do not use this in acceptance tests. Use `loggedIn: true` instead
|
||||
export function logIn() {
|
||||
Discourse.User.resetCurrent(currentUser());
|
||||
User.resetCurrent(currentUser());
|
||||
}
|
||||
|
||||
const Plugin = $.fn.modal;
|
||||
|
@ -119,7 +118,7 @@ export function acceptance(name, options) {
|
|||
}
|
||||
flushMap();
|
||||
localStorage.clear();
|
||||
Discourse.User.resetCurrent();
|
||||
User.resetCurrent();
|
||||
resetSite(Discourse.SiteSettings);
|
||||
resetExtraClasses();
|
||||
clearOutletCache();
|
||||
|
|
|
@ -89,11 +89,12 @@ function dup(obj) {
|
|||
}
|
||||
|
||||
function resetSite(siteSettings, extras) {
|
||||
var createStore = require("helpers/create-store").default;
|
||||
var siteAttrs = $.extend({}, fixtures["site.json"].site, extras || {});
|
||||
let createStore = require("helpers/create-store").default;
|
||||
let siteAttrs = $.extend({}, fixtures["site.json"].site, extras || {});
|
||||
let Site = require("discourse/models/site").default;
|
||||
siteAttrs.store = createStore();
|
||||
siteAttrs.siteSettings = siteSettings;
|
||||
Discourse.Site.resetCurrent(Discourse.Site.create(siteAttrs));
|
||||
Site.resetCurrent(Site.create(siteAttrs));
|
||||
}
|
||||
|
||||
QUnit.testStart(function(ctx) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user