From 70179290f3f3baa91891eb7d3a3308a90d7e8dbc Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 24 May 2018 15:28:54 +1000 Subject: [PATCH] clean up callbacks during acceptance tests --- app/assets/javascripts/discourse/controllers/topic.js.es6 | 4 ++++ test/javascripts/helpers/qunit-helpers.js.es6 | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 7a4bc0535d2..11f4fe4cba1 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -16,6 +16,10 @@ import { userPath } from 'discourse/lib/url'; const customPostMessageCallbacks = {}; +export function resetCustomPostMessageCallbacks() { + customPostMessageCallbacks = {}; +} + export function registerCustomPostMessageCallback(type, callback) { if (customPostMessageCallbacks[type]) { throw `Error ${type} is an already registered post message!`; diff --git a/test/javascripts/helpers/qunit-helpers.js.es6 b/test/javascripts/helpers/qunit-helpers.js.es6 index 1a267c8c435..50bf08bef0d 100644 --- a/test/javascripts/helpers/qunit-helpers.js.es6 +++ b/test/javascripts/helpers/qunit-helpers.js.es6 @@ -10,6 +10,7 @@ import { flushMap } from 'discourse/models/store'; import { clearRewrites } from 'discourse/lib/url'; import { initSearchData } from 'discourse/widgets/search-menu'; import { resetDecorators } from 'discourse/widgets/widget'; +import { resetCustomPostMessageCallbacks } from 'discourse/controllers/topic'; export function currentUser() { return Discourse.User.create(sessionFixtures['/session/current.json'].current_user); @@ -107,6 +108,7 @@ export function acceptance(name, options) { clearRewrites(); initSearchData(); resetDecorators(); + resetCustomPostMessageCallbacks(); Discourse.reset(); } });