FIX: Missing User objects in Utilities
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import ClickTrack from "discourse/lib/click-track";
|
||||
import { fixture, logIn } from "helpers/qunit-helpers";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
QUnit.module("lib:click-track-edit-history", {
|
||||
beforeEach() {
|
||||
@@ -93,7 +94,7 @@ QUnit.skip(
|
||||
"tracks external URLs when opening in another window",
|
||||
async assert => {
|
||||
assert.expect(3);
|
||||
Discourse.User.currentProp("external_links_in_new_tab", true);
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
|
||||
const done = assert.async();
|
||||
/* global server */
|
||||
|
||||
@@ -2,6 +2,7 @@ import { later } from "@ember/runloop";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import ClickTrack from "discourse/lib/click-track";
|
||||
import { fixture, logIn } from "helpers/qunit-helpers";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
QUnit.module("lib:click-track", {
|
||||
beforeEach() {
|
||||
@@ -104,7 +105,7 @@ QUnit.skip(
|
||||
"tracks external URLs when opening in another window",
|
||||
async assert => {
|
||||
assert.expect(3);
|
||||
Discourse.User.currentProp("external_links_in_new_tab", true);
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
|
||||
const done = assert.async();
|
||||
/* global server */
|
||||
@@ -140,7 +141,7 @@ QUnit.skip("does not track right clicks inside quotes", async assert => {
|
||||
});
|
||||
|
||||
QUnit.skip("does not track clicks links in quotes", async assert => {
|
||||
Discourse.User.currentProp("external_links_in_new_tab", true);
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
assert.notOk(track(generateClickEventOn(".quote a:last-child")));
|
||||
assert.ok(window.open.calledWith("https://google.com", "_blank"));
|
||||
});
|
||||
@@ -154,7 +155,7 @@ QUnit.skip("does not track clicks on mailto", async assert => {
|
||||
});
|
||||
|
||||
QUnit.skip("removes the href and put it as a data attribute", async assert => {
|
||||
Discourse.User.currentProp("external_links_in_new_tab", true);
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
|
||||
assert.notOk(track(generateClickEventOn("a")));
|
||||
|
||||
@@ -188,7 +189,7 @@ function badgeClickCount(assert, id, expected) {
|
||||
|
||||
QUnit.skip("does not update badge clicks on my own link", async assert => {
|
||||
sandbox
|
||||
.stub(Discourse.User, "currentProp")
|
||||
.stub(User, "currentProp")
|
||||
.withArgs("id")
|
||||
.returns(314);
|
||||
badgeClickCount(assert, "with-badge", 1);
|
||||
@@ -196,7 +197,7 @@ QUnit.skip("does not update badge clicks on my own link", async assert => {
|
||||
|
||||
QUnit.skip("does not update badge clicks in my own post", async assert => {
|
||||
sandbox
|
||||
.stub(Discourse.User, "currentProp")
|
||||
.stub(User, "currentProp")
|
||||
.withArgs("id")
|
||||
.returns(3141);
|
||||
badgeClickCount(assert, "with-badge-but-not-mine", 1);
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
setCaretPosition,
|
||||
fillMissingDates
|
||||
} from "discourse/lib/utilities";
|
||||
import User from "discourse/models/user";
|
||||
import * as Utilities from "discourse/lib/utilities";
|
||||
|
||||
QUnit.module("lib:utilities");
|
||||
@@ -72,7 +73,7 @@ QUnit.test("uploading one file", assert => {
|
||||
|
||||
QUnit.test("new user cannot upload images", assert => {
|
||||
Discourse.SiteSettings.newuser_max_images = 0;
|
||||
Discourse.User.resetCurrent(Discourse.User.create());
|
||||
User.resetCurrent(User.create());
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(validUpload([{ name: "image.png" }]), "the upload is not valid");
|
||||
@@ -87,7 +88,7 @@ QUnit.test("new user cannot upload images", assert => {
|
||||
QUnit.test("new user cannot upload attachments", assert => {
|
||||
Discourse.SiteSettings.newuser_max_attachments = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
Discourse.User.resetCurrent(Discourse.User.create());
|
||||
User.resetCurrent(User.create());
|
||||
|
||||
assert.not(validUpload([{ name: "roman.txt" }]));
|
||||
assert.ok(
|
||||
@@ -120,7 +121,7 @@ QUnit.test("skipping validation works", assert => {
|
||||
QUnit.test("staff can upload anything in PM", assert => {
|
||||
const files = [{ name: "some.docx" }];
|
||||
Discourse.SiteSettings.authorized_extensions = "jpeg";
|
||||
Discourse.User.resetCurrent(Discourse.User.create({ moderator: true }));
|
||||
User.resetCurrent(User.create({ moderator: true }));
|
||||
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
@@ -151,8 +152,8 @@ var dummyBlob = function() {
|
||||
};
|
||||
|
||||
QUnit.test("allows valid uploads to go through", assert => {
|
||||
Discourse.User.resetCurrent(Discourse.User.create());
|
||||
Discourse.User.currentProp("trust_level", 1);
|
||||
User.resetCurrent(User.create());
|
||||
User.currentProp("trust_level", 1);
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
// image
|
||||
|
||||
Reference in New Issue
Block a user