mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 16:01:38 +08:00
FIX: Pretender errors were being swallowed
Lots of test were broken and needed fixes.
This commit is contained in:
parent
b0564205d9
commit
f1b6b1bd0e
|
@ -119,9 +119,14 @@ export function ajax() {
|
||||||
|
|
||||||
args.error = (xhr, textStatus, errorThrown) => {
|
args.error = (xhr, textStatus, errorThrown) => {
|
||||||
// 0 represents the `UNSENT` state
|
// 0 represents the `UNSENT` state
|
||||||
if (xhr.readyState === 0 && !isTesting()) {
|
if (xhr.readyState === 0) {
|
||||||
|
// Make sure we log pretender errors in test mode
|
||||||
|
if (isTesting()) {
|
||||||
|
throw errorThrown;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLogoff(xhr);
|
handleLogoff(xhr);
|
||||||
|
|
||||||
// note: for bad CSRF we don't loop an extra request right away.
|
// note: for bad CSRF we don't loop an extra request right away.
|
||||||
|
|
|
@ -859,10 +859,6 @@ QUnit.test("can reply to a private message", async assert => {
|
||||||
return [200, { "Content-Type": "application/json" }, {}];
|
return [200, { "Content-Type": "application/json" }, {}];
|
||||||
});
|
});
|
||||||
|
|
||||||
// a bit messy but we need a fake here cause we issue a route transition
|
|
||||||
// to the new post
|
|
||||||
server.get("/t/34/4.json", () => server.get("/t/34.json"));
|
|
||||||
|
|
||||||
await visit("/t/34");
|
await visit("/t/34");
|
||||||
await click(".topic-post:eq(0) button.reply");
|
await click(".topic-post:eq(0) button.reply");
|
||||||
await fillIn(".d-editor-input", "this is the *content* of the reply");
|
await fillIn(".d-editor-input", "this is the *content* of the reply");
|
||||||
|
|
|
@ -2,20 +2,22 @@ import User from "discourse/models/user";
|
||||||
|
|
||||||
export function parsePostData(query) {
|
export function parsePostData(query) {
|
||||||
const result = {};
|
const result = {};
|
||||||
query.split("&").forEach(function(part) {
|
if (query) {
|
||||||
const item = part.split("=");
|
query.split("&").forEach(function(part) {
|
||||||
const firstSeg = decodeURIComponent(item[0]);
|
const item = part.split("=");
|
||||||
const m = /^([^\[]+)\[(.+)\]/.exec(firstSeg);
|
const firstSeg = decodeURIComponent(item[0]);
|
||||||
|
const m = /^([^\[]+)\[(.+)\]/.exec(firstSeg);
|
||||||
|
|
||||||
const val = decodeURIComponent(item[1]).replace(/\+/g, " ");
|
const val = decodeURIComponent(item[1]).replace(/\+/g, " ");
|
||||||
if (m) {
|
if (m) {
|
||||||
let key = m[1];
|
let key = m[1];
|
||||||
result[key] = result[key] || {};
|
result[key] = result[key] || {};
|
||||||
result[key][m[2].replace("][", ".")] = val;
|
result[key][m[2].replace("][", ".")] = val;
|
||||||
} else {
|
} else {
|
||||||
result[firstSeg] = val;
|
result[firstSeg] = val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,6 +247,7 @@ export function applyDefaultHandlers(pretender) {
|
||||||
|
|
||||||
pretender.get("/t/280.json", () => response(fixturesByUrl["/t/280/1.json"]));
|
pretender.get("/t/280.json", () => response(fixturesByUrl["/t/280/1.json"]));
|
||||||
pretender.get("/t/34.json", () => response(fixturesByUrl["/t/34/1.json"]));
|
pretender.get("/t/34.json", () => response(fixturesByUrl["/t/34/1.json"]));
|
||||||
|
pretender.get("/t/34/4.json", () => response(fixturesByUrl["/t/34/1.json"]));
|
||||||
pretender.get("/t/280/:post_number.json", () =>
|
pretender.get("/t/280/:post_number.json", () =>
|
||||||
response(fixturesByUrl["/t/280/1.json"])
|
response(fixturesByUrl["/t/280/1.json"])
|
||||||
);
|
);
|
||||||
|
@ -255,7 +258,9 @@ export function applyDefaultHandlers(pretender) {
|
||||||
pretender.get("/t/12.json", () => response(fixturesByUrl["/t/12/1.json"]));
|
pretender.get("/t/12.json", () => response(fixturesByUrl["/t/12/1.json"]));
|
||||||
pretender.put("/t/1234/re-pin", success);
|
pretender.put("/t/1234/re-pin", success);
|
||||||
|
|
||||||
pretender.get("/t/2480.json", () => response(fixturesByUrl["/t/2480/1.json"]));
|
pretender.get("/t/2480.json", () =>
|
||||||
|
response(fixturesByUrl["/t/2480/1.json"])
|
||||||
|
);
|
||||||
|
|
||||||
pretender.get("/t/id_for/:slug", () => {
|
pretender.get("/t/id_for/:slug", () => {
|
||||||
return response({
|
return response({
|
||||||
|
|
|
@ -4,7 +4,9 @@ import badgeFixtures from "fixtures/user-badges";
|
||||||
QUnit.module("model:user-badge");
|
QUnit.module("model:user-badge");
|
||||||
|
|
||||||
QUnit.test("createFromJson single", assert => {
|
QUnit.test("createFromJson single", assert => {
|
||||||
const userBadge = UserBadge.createFromJson(badgeFixtures["/user_badges"]);
|
const userBadge = UserBadge.createFromJson(
|
||||||
|
JSON.parse(JSON.stringify(badgeFixtures["/user_badges"]))
|
||||||
|
);
|
||||||
assert.ok(!Array.isArray(userBadge), "does not return an array");
|
assert.ok(!Array.isArray(userBadge), "does not return an array");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
userBadge.get("badge.name"),
|
userBadge.get("badge.name"),
|
||||||
|
@ -25,7 +27,7 @@ QUnit.test("createFromJson single", assert => {
|
||||||
|
|
||||||
QUnit.test("createFromJson array", assert => {
|
QUnit.test("createFromJson array", assert => {
|
||||||
const userBadges = UserBadge.createFromJson(
|
const userBadges = UserBadge.createFromJson(
|
||||||
badgeFixtures["/user-badges/:username"]
|
JSON.parse(JSON.stringify(badgeFixtures["/user-badges/:username"]))
|
||||||
);
|
);
|
||||||
assert.ok(Array.isArray(userBadges), "returns an array");
|
assert.ok(Array.isArray(userBadges), "returns an array");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user