mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
DEV: Fix pretenders leaking across acceptance test.
This commit is contained in:
parent
c780d36ddc
commit
c80ab08e48
|
@ -4,10 +4,6 @@ acceptance("Tag Hashtag", {
|
|||
loggedIn: true,
|
||||
settings: { tagging_enabled: true },
|
||||
pretend(server, helper) {
|
||||
server.get("/tags/filter/search", () => {
|
||||
return helper.response({ results: [{ text: "monkey", count: 1 }] });
|
||||
});
|
||||
|
||||
server.get("/tags/check", () => {
|
||||
return helper.response({
|
||||
valid: [{ value: "monkey", url: "/tags/monkey" }]
|
||||
|
|
|
@ -14,13 +14,6 @@ acceptance("Topic - Edit timer", {
|
|||
category_id: null
|
||||
})
|
||||
);
|
||||
|
||||
server.put("/t/internationalization-localization/280/status", () =>
|
||||
helper.response({
|
||||
success: "OK",
|
||||
topic_status_update: null
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -7,18 +7,6 @@ acceptance("Topic", {
|
|||
server.put("/posts/398/wiki", () => {
|
||||
return helper.response({});
|
||||
});
|
||||
|
||||
server.get("/topics/feature_stats.json", () => {
|
||||
return helper.response({
|
||||
pinned_in_category_count: 0,
|
||||
pinned_globally_count: 0,
|
||||
banner_count: 0
|
||||
});
|
||||
});
|
||||
|
||||
server.put("/t/280/make-banner", () => {
|
||||
return helper.response({});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -85,6 +85,10 @@ export default function() {
|
|||
});
|
||||
});
|
||||
|
||||
this.get("/tags/filter/search", () => {
|
||||
return response({ results: [{ text: "monkey", count: 1 }] });
|
||||
});
|
||||
|
||||
this.get(`/u/:username/emails.json`, () => {
|
||||
return response({ email: "eviltrout@example.com" });
|
||||
});
|
||||
|
@ -138,6 +142,25 @@ export default function() {
|
|||
return response({ topic_list: { topics: [] } });
|
||||
});
|
||||
|
||||
this.get("/topics/feature_stats.json", () => {
|
||||
return response({
|
||||
pinned_in_category_count: 0,
|
||||
pinned_globally_count: 0,
|
||||
banner_count: 0
|
||||
});
|
||||
});
|
||||
|
||||
this.put("/t/280/make-banner", () => {
|
||||
return response({});
|
||||
});
|
||||
|
||||
this.put("/t/internationalization-localization/280/status", () => {
|
||||
return response({
|
||||
success: "OK",
|
||||
topic_status_update: null
|
||||
});
|
||||
});
|
||||
|
||||
this.post("/clicks/track", success);
|
||||
|
||||
this.get("/search", request => {
|
||||
|
|
|
@ -57,17 +57,18 @@ function AcceptanceModal(option, _relatedTarget) {
|
|||
window.bootbox.$body = $("#ember-testing");
|
||||
$.fn.modal = AcceptanceModal;
|
||||
|
||||
let _pretenderCallbacks = [];
|
||||
let _pretenderCallbacks = {};
|
||||
|
||||
export function applyPretender(server, helper) {
|
||||
_pretenderCallbacks.forEach(cb => cb(server, helper));
|
||||
export function applyPretender(name, server, helper) {
|
||||
const cb = _pretenderCallbacks[name];
|
||||
if (cb) cb(server, helper);
|
||||
}
|
||||
|
||||
export function acceptance(name, options) {
|
||||
options = options || {};
|
||||
|
||||
if (options.pretend) {
|
||||
_pretenderCallbacks.push(options.pretend);
|
||||
_pretenderCallbacks[name] = options.pretend;
|
||||
}
|
||||
|
||||
QUnit.module("Acceptance: " + name, {
|
||||
|
|
|
@ -88,7 +88,8 @@ var origDebounce = Ember.run.debounce,
|
|||
_DiscourseURL = require("discourse/lib/url", null, null, false).default,
|
||||
applyPretender = require("helpers/qunit-helpers", null, null, false)
|
||||
.applyPretender,
|
||||
server;
|
||||
server,
|
||||
acceptanceModulePrefix = "Acceptance: ";
|
||||
|
||||
function dup(obj) {
|
||||
return jQuery.extend(true, {}, obj);
|
||||
|
@ -105,13 +106,15 @@ function resetSite(siteSettings, extras) {
|
|||
QUnit.testStart(function(ctx) {
|
||||
server = pretender.default();
|
||||
|
||||
var helper = {
|
||||
parsePostData: pretender.parsePostData,
|
||||
response: pretender.response,
|
||||
success: pretender.success
|
||||
};
|
||||
if (ctx.module.startsWith(acceptanceModulePrefix)) {
|
||||
var helper = {
|
||||
parsePostData: pretender.parsePostData,
|
||||
response: pretender.response,
|
||||
success: pretender.success
|
||||
};
|
||||
|
||||
applyPretender(server, helper);
|
||||
applyPretender(ctx.module.replace(acceptanceModulePrefix, ""), server, helper);
|
||||
}
|
||||
|
||||
// Allow our tests to change site settings and have them reset before the next test
|
||||
Discourse.SiteSettings = dup(Discourse.SiteSettingsOriginal);
|
||||
|
|
Loading…
Reference in New Issue
Block a user