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:
@@ -1,6 +1,7 @@
|
||||
import createStore from "helpers/create-store";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:category-link");
|
||||
discourseModule("lib:category-link");
|
||||
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
|
||||
@@ -82,8 +83,8 @@ QUnit.test("allowUncategorized", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("category names are wrapped in dir-spans", assert => {
|
||||
Discourse.SiteSettings.support_mixed_text_direction = true;
|
||||
QUnit.test("category names are wrapped in dir-spans", function(assert) {
|
||||
this.siteSettings.support_mixed_text_direction = true;
|
||||
const store = createStore();
|
||||
const rtlCategory = store.createRecord("category", {
|
||||
name: "תכנות עם Ruby",
|
||||
@@ -107,7 +108,7 @@ QUnit.test("category names are wrapped in dir-spans", assert => {
|
||||
assert.equal(dirSpan.dir, "ltr");
|
||||
});
|
||||
|
||||
QUnit.test("recursive", assert => {
|
||||
QUnit.test("recursive", function(assert) {
|
||||
const store = createStore();
|
||||
|
||||
const foo = store.createRecord("category", {
|
||||
@@ -127,20 +128,20 @@ QUnit.test("recursive", assert => {
|
||||
parent_category_id: bar.id
|
||||
});
|
||||
|
||||
Discourse.set("SiteSettings.max_category_nesting", 0);
|
||||
this.siteSettings.max_category_nesting = 0;
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1);
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") === -1);
|
||||
|
||||
Discourse.set("SiteSettings.max_category_nesting", 1);
|
||||
this.siteSettings.max_category_nesting = 1;
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1);
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") === -1);
|
||||
|
||||
Discourse.set("SiteSettings.max_category_nesting", 2);
|
||||
this.siteSettings.max_category_nesting = 2;
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1);
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") !== -1);
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("foo") === -1);
|
||||
|
||||
Discourse.set("SiteSettings.max_category_nesting", 3);
|
||||
this.siteSettings.max_category_nesting = 3;
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1);
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") !== -1);
|
||||
assert.ok(categoryBadgeHTML(baz, { recursive: true }).indexOf("foo") !== -1);
|
||||
|
||||
@@ -10,8 +10,9 @@ import {
|
||||
htmlSafe
|
||||
} from "discourse/lib/computed";
|
||||
import { setPrefix } from "discourse-common/lib/get-url";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:computed", {
|
||||
discourseModule("lib:computed", {
|
||||
beforeEach() {
|
||||
sandbox.stub(I18n, "t").callsFake(function(scope) {
|
||||
return "%@ translated: " + scope;
|
||||
@@ -23,13 +24,13 @@ QUnit.module("lib:computed", {
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("setting", assert => {
|
||||
QUnit.test("setting", function(assert) {
|
||||
var t = EmberObject.extend({
|
||||
vehicle: setting("vehicle"),
|
||||
missingProp: setting("madeUpThing")
|
||||
}).create();
|
||||
|
||||
Discourse.SiteSettings.vehicle = "airplane";
|
||||
this.siteSettings.vehicle = "airplane";
|
||||
assert.equal(
|
||||
t.get("vehicle"),
|
||||
"airplane",
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { emojiSearch } from "pretty-text/emoji";
|
||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||
import { emojiUnescape } from "discourse/lib/text";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:emoji");
|
||||
discourseModule("lib:emoji");
|
||||
|
||||
QUnit.test("emojiUnescape", assert => {
|
||||
QUnit.test("emojiUnescape", function(assert) {
|
||||
const testUnescape = (input, expected, description, settings = {}) => {
|
||||
const originalSettings = {};
|
||||
for (const [key, value] of Object.entries(settings)) {
|
||||
originalSettings[key] = Discourse.SiteSettings[key];
|
||||
Discourse.SiteSettings[key] = value;
|
||||
originalSettings[key] = this.siteSettings[key];
|
||||
this.siteSettings[key] = value;
|
||||
}
|
||||
|
||||
assert.equal(emojiUnescape(input), expected, description);
|
||||
|
||||
for (const [key, value] of Object.entries(originalSettings)) {
|
||||
Discourse.SiteSettings[key] = value;
|
||||
this.siteSettings[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
var clock;
|
||||
|
||||
import {
|
||||
relativeAge,
|
||||
autoUpdatingRelativeAge,
|
||||
@@ -8,98 +6,126 @@ import {
|
||||
longDate,
|
||||
durationTiny
|
||||
} from "discourse/lib/formatter";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:formatter", {
|
||||
discourseModule("lib:formatter", {
|
||||
beforeEach() {
|
||||
clock = sinon.useFakeTimers(new Date(2012, 11, 31, 12, 0).getTime());
|
||||
this.clock = sinon.useFakeTimers(new Date(2012, 11, 31, 12, 0).getTime());
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
clock.restore();
|
||||
this.clock.restore();
|
||||
}
|
||||
});
|
||||
|
||||
var format = "tiny";
|
||||
var leaveAgo = false;
|
||||
var mins_ago = function(mins) {
|
||||
return new Date(new Date() - mins * 60 * 1000);
|
||||
};
|
||||
function formatMins(mins, opts = {}) {
|
||||
let dt = new Date(new Date() - mins * 60 * 1000);
|
||||
return relativeAge(dt, {
|
||||
format: opts.format || "tiny",
|
||||
leaveAgo: opts.leaveAgo
|
||||
});
|
||||
}
|
||||
|
||||
var formatMins = function(mins) {
|
||||
return relativeAge(mins_ago(mins), { format: format, leaveAgo: leaveAgo });
|
||||
};
|
||||
function formatHours(hours, opts) {
|
||||
return formatMins(hours * 60, opts);
|
||||
}
|
||||
|
||||
var formatHours = function(hours) {
|
||||
return formatMins(hours * 60);
|
||||
};
|
||||
function formatDays(days, opts) {
|
||||
return formatHours(days * 24, opts);
|
||||
}
|
||||
|
||||
var formatDays = function(days) {
|
||||
return formatHours(days * 24);
|
||||
};
|
||||
|
||||
var shortDate = function(days) {
|
||||
function shortDate(days) {
|
||||
return moment()
|
||||
.subtract(days, "days")
|
||||
.format("MMM D");
|
||||
};
|
||||
}
|
||||
|
||||
QUnit.test("formating medium length dates", assert => {
|
||||
format = "medium";
|
||||
var strip = function(html) {
|
||||
return $(html).text();
|
||||
};
|
||||
|
||||
var shortDateYear = function(days) {
|
||||
function shortDateTester(format) {
|
||||
return function(days) {
|
||||
return moment()
|
||||
.subtract(days, "days")
|
||||
.format("MMM D, 'YY");
|
||||
.format(format);
|
||||
};
|
||||
}
|
||||
|
||||
leaveAgo = true;
|
||||
assert.equal(strip(formatMins(1.4)), "1 min ago");
|
||||
assert.equal(strip(formatMins(2)), "2 mins ago");
|
||||
assert.equal(strip(formatMins(55)), "55 mins ago");
|
||||
assert.equal(strip(formatMins(56)), "1 hour ago");
|
||||
assert.equal(strip(formatHours(4)), "4 hours ago");
|
||||
assert.equal(strip(formatHours(22)), "22 hours ago");
|
||||
assert.equal(strip(formatHours(23)), "23 hours ago");
|
||||
assert.equal(strip(formatHours(23.5)), "1 day ago");
|
||||
assert.equal(strip(formatDays(4.85)), "4 days ago");
|
||||
function strip(html) {
|
||||
return $(html).text();
|
||||
}
|
||||
|
||||
leaveAgo = false;
|
||||
assert.equal(strip(formatMins(0)), "just now");
|
||||
assert.equal(strip(formatMins(1.4)), "1 min");
|
||||
assert.equal(strip(formatMins(2)), "2 mins");
|
||||
assert.equal(strip(formatMins(55)), "55 mins");
|
||||
assert.equal(strip(formatMins(56)), "1 hour");
|
||||
assert.equal(strip(formatHours(4)), "4 hours");
|
||||
assert.equal(strip(formatHours(22)), "22 hours");
|
||||
assert.equal(strip(formatHours(23)), "23 hours");
|
||||
assert.equal(strip(formatHours(23.5)), "1 day");
|
||||
assert.equal(strip(formatDays(4.85)), "4 days");
|
||||
QUnit.test("formating medium length dates", function(assert) {
|
||||
let shortDateYear = shortDateTester("MMM D, 'YY");
|
||||
|
||||
assert.equal(strip(formatDays(6)), shortDate(6));
|
||||
assert.equal(strip(formatDays(100)), shortDate(100)); // eg: Jan 23
|
||||
assert.equal(strip(formatDays(500)), shortDateYear(500));
|
||||
assert.equal(
|
||||
strip(formatMins(1.4, { format: "medium", leaveAgo: true })),
|
||||
"1 min ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatMins(2, { format: "medium", leaveAgo: true })),
|
||||
"2 mins ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatMins(55, { format: "medium", leaveAgo: true })),
|
||||
"55 mins ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatMins(56, { format: "medium", leaveAgo: true })),
|
||||
"1 hour ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatHours(4, { format: "medium", leaveAgo: true })),
|
||||
"4 hours ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatHours(22, { format: "medium", leaveAgo: true })),
|
||||
"22 hours ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatHours(23, { format: "medium", leaveAgo: true })),
|
||||
"23 hours ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatHours(23.5, { format: "medium", leaveAgo: true })),
|
||||
"1 day ago"
|
||||
);
|
||||
assert.equal(
|
||||
strip(formatDays(4.85, { format: "medium", leaveAgo: true })),
|
||||
"4 days ago"
|
||||
);
|
||||
|
||||
assert.equal($(formatDays(0)).attr("title"), longDate(new Date()));
|
||||
assert.equal($(formatDays(0)).attr("class"), "date");
|
||||
assert.equal(strip(formatMins(0, { format: "medium" })), "just now");
|
||||
assert.equal(strip(formatMins(1.4, { format: "medium" })), "1 min");
|
||||
assert.equal(strip(formatMins(2, { format: "medium" })), "2 mins");
|
||||
assert.equal(strip(formatMins(55, { format: "medium" })), "55 mins");
|
||||
assert.equal(strip(formatMins(56, { format: "medium" })), "1 hour");
|
||||
assert.equal(strip(formatHours(4, { format: "medium" })), "4 hours");
|
||||
assert.equal(strip(formatHours(22, { format: "medium" })), "22 hours");
|
||||
assert.equal(strip(formatHours(23, { format: "medium" })), "23 hours");
|
||||
assert.equal(strip(formatHours(23.5, { format: "medium" })), "1 day");
|
||||
assert.equal(strip(formatDays(4.85, { format: "medium" })), "4 days");
|
||||
|
||||
clock.restore();
|
||||
clock = sinon.useFakeTimers(new Date(2012, 0, 9, 12, 0).getTime()); // Jan 9, 2012
|
||||
assert.equal(strip(formatDays(6, { format: "medium" })), shortDate(6));
|
||||
assert.equal(strip(formatDays(100, { format: "medium" })), shortDate(100)); // eg: Jan 23
|
||||
assert.equal(
|
||||
strip(formatDays(500, { format: "medium" })),
|
||||
shortDateYear(500)
|
||||
);
|
||||
|
||||
assert.equal(strip(formatDays(8)), shortDate(8));
|
||||
assert.equal(strip(formatDays(10)), shortDateYear(10));
|
||||
assert.equal(
|
||||
$(formatDays(0, { format: "medium" })).attr("title"),
|
||||
longDate(new Date())
|
||||
);
|
||||
assert.equal($(formatDays(0, { format: "medium" })).attr("class"), "date");
|
||||
|
||||
this.clock.restore();
|
||||
this.clock = sinon.useFakeTimers(new Date(2012, 0, 9, 12, 0).getTime()); // Jan 9, 2012
|
||||
|
||||
assert.equal(strip(formatDays(8, { format: "medium" })), shortDate(8));
|
||||
assert.equal(strip(formatDays(10, { format: "medium" })), shortDateYear(10));
|
||||
});
|
||||
|
||||
QUnit.test("formating tiny dates", assert => {
|
||||
var shortDateYear = function(days) {
|
||||
return moment()
|
||||
.subtract(days, "days")
|
||||
.format("MMM 'YY");
|
||||
};
|
||||
QUnit.test("formating tiny dates", function(assert) {
|
||||
let shortDateYear = shortDateTester("MMM 'YY");
|
||||
|
||||
format = "tiny";
|
||||
assert.equal(formatMins(0), "1m");
|
||||
assert.equal(formatMins(1), "1m");
|
||||
assert.equal(formatMins(2), "2m");
|
||||
@@ -117,16 +143,16 @@ QUnit.test("formating tiny dates", assert => {
|
||||
assert.equal(formatDays(500), shortDateYear(500));
|
||||
assert.equal(formatDays(365 * 2 + 1), shortDateYear(365 * 2 + 1)); // one leap year
|
||||
|
||||
var originalValue = Discourse.SiteSettings.relative_date_duration;
|
||||
Discourse.SiteSettings.relative_date_duration = 7;
|
||||
var originalValue = this.siteSettings.relative_date_duration;
|
||||
this.siteSettings.relative_date_duration = 7;
|
||||
assert.equal(formatDays(7), "7d");
|
||||
assert.equal(formatDays(8), shortDate(8));
|
||||
|
||||
Discourse.SiteSettings.relative_date_duration = 1;
|
||||
this.siteSettings.relative_date_duration = 1;
|
||||
assert.equal(formatDays(1), "1d");
|
||||
assert.equal(formatDays(2), shortDate(2));
|
||||
|
||||
Discourse.SiteSettings.relative_date_duration = 0;
|
||||
this.siteSettings.relative_date_duration = 0;
|
||||
assert.equal(formatMins(0), "1m");
|
||||
assert.equal(formatMins(1), "1m");
|
||||
assert.equal(formatMins(2), "2m");
|
||||
@@ -135,32 +161,32 @@ QUnit.test("formating tiny dates", assert => {
|
||||
assert.equal(formatDays(2), shortDate(2));
|
||||
assert.equal(formatDays(366), shortDateYear(366));
|
||||
|
||||
Discourse.SiteSettings.relative_date_duration = null;
|
||||
this.siteSettings.relative_date_duration = null;
|
||||
assert.equal(formatDays(1), "1d");
|
||||
assert.equal(formatDays(14), "14d");
|
||||
assert.equal(formatDays(15), shortDate(15));
|
||||
|
||||
Discourse.SiteSettings.relative_date_duration = 14;
|
||||
this.siteSettings.relative_date_duration = 14;
|
||||
|
||||
clock.restore();
|
||||
clock = sinon.useFakeTimers(new Date(2012, 0, 12, 12, 0).getTime()); // Jan 12, 2012
|
||||
this.clock.restore();
|
||||
this.clock = sinon.useFakeTimers(new Date(2012, 0, 12, 12, 0).getTime()); // Jan 12, 2012
|
||||
|
||||
assert.equal(formatDays(11), "11d");
|
||||
assert.equal(formatDays(14), "14d");
|
||||
assert.equal(formatDays(15), shortDateYear(15));
|
||||
assert.equal(formatDays(366), shortDateYear(366));
|
||||
|
||||
clock.restore();
|
||||
clock = sinon.useFakeTimers(new Date(2012, 0, 20, 12, 0).getTime()); // Jan 20, 2012
|
||||
this.clock.restore();
|
||||
this.clock = sinon.useFakeTimers(new Date(2012, 0, 20, 12, 0).getTime()); // Jan 20, 2012
|
||||
|
||||
assert.equal(formatDays(14), "14d");
|
||||
assert.equal(formatDays(15), shortDate(15));
|
||||
assert.equal(formatDays(20), shortDateYear(20));
|
||||
|
||||
Discourse.SiteSettings.relative_date_duration = originalValue;
|
||||
this.siteSettings.relative_date_duration = originalValue;
|
||||
});
|
||||
|
||||
QUnit.test("autoUpdatingRelativeAge", assert => {
|
||||
QUnit.test("autoUpdatingRelativeAge", function(assert) {
|
||||
var d = moment()
|
||||
.subtract(1, "day")
|
||||
.toDate();
|
||||
@@ -192,7 +218,7 @@ QUnit.test("autoUpdatingRelativeAge", assert => {
|
||||
assert.equal($elem.html(), "1 day");
|
||||
});
|
||||
|
||||
QUnit.test("updateRelativeAge", assert => {
|
||||
QUnit.test("updateRelativeAge", function(assert) {
|
||||
var d = new Date();
|
||||
var $elem = $(autoUpdatingRelativeAge(d));
|
||||
$elem.data("time", d.getTime() - 2 * 60 * 1000);
|
||||
@@ -210,7 +236,7 @@ QUnit.test("updateRelativeAge", assert => {
|
||||
assert.equal($elem.html(), "2 mins ago");
|
||||
});
|
||||
|
||||
QUnit.test("number", assert => {
|
||||
QUnit.test("number", function(assert) {
|
||||
assert.equal(number(123), "123", "it returns a string version of the number");
|
||||
assert.equal(number("123"), "123", "it works with a string command");
|
||||
assert.equal(number(NaN), "0", "it returns 0 for NaN");
|
||||
@@ -241,7 +267,7 @@ QUnit.test("number", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("durationTiny", assert => {
|
||||
QUnit.test("durationTiny", function(assert) {
|
||||
assert.equal(durationTiny(), "—", "undefined is a dash");
|
||||
assert.equal(durationTiny(null), "—", "null is a dash");
|
||||
assert.equal(durationTiny(0), "< 1m", "0 seconds shows as < 1m");
|
||||
|
||||
@@ -9,8 +9,9 @@ import {
|
||||
} from "discourse/lib/uploads";
|
||||
import * as Utilities from "discourse/lib/utilities";
|
||||
import User from "discourse/models/user";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:uploads");
|
||||
discourseModule("lib:uploads");
|
||||
|
||||
const validUpload = validateUploadedFiles;
|
||||
|
||||
@@ -27,8 +28,8 @@ QUnit.test("uploading one file", assert => {
|
||||
assert.ok(bootbox.alert.calledWith(I18n.t("post.errors.too_many_uploads")));
|
||||
});
|
||||
|
||||
QUnit.test("new user cannot upload images", assert => {
|
||||
Discourse.SiteSettings.newuser_max_images = 0;
|
||||
QUnit.test("new user cannot upload images", function(assert) {
|
||||
this.siteSettings.newuser_max_images = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(
|
||||
@@ -43,8 +44,8 @@ QUnit.test("new user cannot upload images", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("new user cannot upload attachments", assert => {
|
||||
Discourse.SiteSettings.newuser_max_attachments = 0;
|
||||
QUnit.test("new user cannot upload attachments", function(assert) {
|
||||
this.siteSettings.newuser_max_attachments = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(validUpload([{ name: "roman.txt" }], { user: User.create() }));
|
||||
@@ -75,9 +76,9 @@ QUnit.test("skipping validation works", assert => {
|
||||
assert.ok(validUpload(files, { skipValidation: true }));
|
||||
});
|
||||
|
||||
QUnit.test("staff can upload anything in PM", assert => {
|
||||
QUnit.test("staff can upload anything in PM", function(assert) {
|
||||
const files = [{ name: "some.docx" }];
|
||||
Discourse.SiteSettings.authorized_extensions = "jpeg";
|
||||
this.siteSettings.authorized_extensions = "jpeg";
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
let user = User.create({ moderator: true });
|
||||
@@ -137,43 +138,43 @@ QUnit.test("isImage", assert => {
|
||||
assert.not(isImage(""));
|
||||
});
|
||||
|
||||
QUnit.test("allowsImages", assert => {
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
QUnit.test("allowsImages", function(assert) {
|
||||
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
assert.ok(allowsImages(), "works");
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = ".jpg|.jpeg|.gif";
|
||||
this.siteSettings.authorized_extensions = ".jpg|.jpeg|.gif";
|
||||
assert.ok(allowsImages(), "works with old extensions syntax");
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = "txt|pdf|*";
|
||||
this.siteSettings.authorized_extensions = "txt|pdf|*";
|
||||
assert.ok(
|
||||
allowsImages(),
|
||||
"images are allowed when all extensions are allowed"
|
||||
);
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = "json|jpg|pdf|txt";
|
||||
this.siteSettings.authorized_extensions = "json|jpg|pdf|txt";
|
||||
assert.ok(
|
||||
allowsImages(),
|
||||
"images are allowed when at least one extension is an image extension"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("allowsAttachments", assert => {
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
QUnit.test("allowsAttachments", function(assert) {
|
||||
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
assert.not(allowsAttachments(), "no attachments allowed by default");
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif|*";
|
||||
this.siteSettings.authorized_extensions = "jpg|jpeg|gif|*";
|
||||
assert.ok(
|
||||
allowsAttachments(),
|
||||
"attachments are allowed when all extensions are allowed"
|
||||
);
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif|pdf";
|
||||
this.siteSettings.authorized_extensions = "jpg|jpeg|gif|pdf";
|
||||
assert.ok(
|
||||
allowsAttachments(),
|
||||
"attachments are allowed when at least one extension is not an image extension"
|
||||
);
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = ".jpg|.jpeg|.gif|.pdf";
|
||||
this.siteSettings.authorized_extensions = ".jpg|.jpeg|.gif|.pdf";
|
||||
assert.ok(allowsAttachments(), "works with old extensions syntax");
|
||||
});
|
||||
|
||||
|
||||
@@ -16,15 +16,12 @@ import {
|
||||
inCodeBlock
|
||||
} from "discourse/lib/utilities";
|
||||
import Handlebars from "handlebars";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:utilities");
|
||||
discourseModule("lib:utilities");
|
||||
|
||||
QUnit.test("escapeExpression", assert => {
|
||||
assert.equal(
|
||||
escapeExpression(">"),
|
||||
">",
|
||||
"escapes unsafe characters"
|
||||
);
|
||||
assert.equal(escapeExpression(">"), ">", "escapes unsafe characters");
|
||||
|
||||
assert.equal(
|
||||
escapeExpression(new Handlebars.SafeString(">")),
|
||||
@@ -135,8 +132,8 @@ QUnit.test("avatarImg", assert => {
|
||||
setDevicePixelRatio(oldRatio);
|
||||
});
|
||||
|
||||
QUnit.test("defaultHomepage", assert => {
|
||||
Discourse.SiteSettings.top_menu = "latest|top|hot";
|
||||
QUnit.test("defaultHomepage", function(assert) {
|
||||
this.siteSettings.top_menu = "latest|top|hot";
|
||||
assert.equal(
|
||||
defaultHomepage(),
|
||||
"latest",
|
||||
|
||||
Reference in New Issue
Block a user