From 3d0b3103680e374679dc6928eae5fcc2392f5bed Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 13 Nov 2019 12:35:19 -0500 Subject: [PATCH] DEV: Fix some more deprecated Discourse.User and Discourse.Site --- test/javascripts/helpers/create-pretender.js.es6 | 4 +++- test/javascripts/helpers/qunit-helpers.js.es6 | 11 +++++------ test/javascripts/test_helper.js | 7 ++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6 index 22d1618edcf..46e9e11c84d 100644 --- a/test/javascripts/helpers/create-pretender.js.es6 +++ b/test/javascripts/helpers/create-pretender.js.es6 @@ -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; diff --git a/test/javascripts/helpers/qunit-helpers.js.es6 b/test/javascripts/helpers/qunit-helpers.js.es6 index 59f00c71ecd..25dcb2a3d8d 100644 --- a/test/javascripts/helpers/qunit-helpers.js.es6 +++ b/test/javascripts/helpers/qunit-helpers.js.es6 @@ -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(); diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js index c3077d83044..d0fc2b45c0e 100644 --- a/test/javascripts/test_helper.js +++ b/test/javascripts/test_helper.js @@ -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) {