DEV: prevents post-cooked decorators to leak between tests (#7744)

This commit is contained in:
Joffrey JAFFEUX 2019-06-11 10:02:10 +02:00 committed by GitHub
parent 62c56b6e59
commit 4deb0f6d59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -4,13 +4,17 @@ import { isValidLink } from "discourse/lib/click-track";
import { number } from "discourse/lib/formatter"; import { number } from "discourse/lib/formatter";
import highlightText from "discourse/lib/highlight-text"; import highlightText from "discourse/lib/highlight-text";
const _decorators = []; let _decorators = [];
// Don't call this directly: use `plugin-api/decorateCooked` // Don't call this directly: use `plugin-api/decorateCooked`
export function addDecorator(cb) { export function addDecorator(cb) {
_decorators.push(cb); _decorators.push(cb);
} }
export function resetDecorators() {
_decorators = [];
}
export default class PostCooked { export default class PostCooked {
constructor(attrs, decoratorHelper, currentUser) { constructor(attrs, decoratorHelper, currentUser) {
this.attrs = attrs; this.attrs = attrs;

View File

@ -13,6 +13,7 @@ import { flushMap } from "discourse/models/store";
import { clearRewrites } from "discourse/lib/url"; import { clearRewrites } from "discourse/lib/url";
import { initSearchData } from "discourse/widgets/search-menu"; import { initSearchData } from "discourse/widgets/search-menu";
import { resetDecorators } from "discourse/widgets/widget"; import { resetDecorators } from "discourse/widgets/widget";
import { resetDecorators as resetPostCookedDecorators } from "discourse/widgets/post-cooked";
import { resetCache as resetOneboxCache } from "pretty-text/oneboxer"; import { resetCache as resetOneboxCache } from "pretty-text/oneboxer";
import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic"; import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
@ -124,6 +125,7 @@ export function acceptance(name, options) {
clearRewrites(); clearRewrites();
initSearchData(); initSearchData();
resetDecorators(); resetDecorators();
resetPostCookedDecorators();
resetOneboxCache(); resetOneboxCache();
resetCustomPostMessageCallbacks(); resetCustomPostMessageCallbacks();
Discourse.reset(); Discourse.reset();