DEV: Fix some more deprecated Discourse.User and Discourse.Site

This commit is contained in:
Robin Ward 2019-11-13 12:35:19 -05:00
parent 4843414de6
commit 3d0b310368
3 changed files with 12 additions and 10 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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) {