FIX: currentUser was missing `appEvents` (#11758)

This commit is contained in:
Robin Ward 2021-01-19 14:37:21 -05:00 committed by GitHub
parent e968af6dd4
commit cdaa506397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -117,8 +117,10 @@ export default {
},
teardown() {
this.keyTrapper.reset();
this.keyTrapper = null;
if (this.keyTrapper) {
this.keyTrapper.reset();
this.keyTrapper = null;
}
this.container = null;
},

View File

@ -42,6 +42,10 @@ export default {
let siteSettings = container.lookup("site-settings:main");
ALL_TARGETS.forEach((t) =>
app.inject(t, "appEvents", "service:app-events")
);
const currentUser = User.current();
app.register("current-user:main", currentUser, { instantiate: false });
app.currentUser = currentUser;
@ -82,10 +86,6 @@ export default {
ALL_TARGETS.forEach((t) => app.inject(t, "store", "service:store"));
ALL_TARGETS.forEach((t) =>
app.inject(t, "appEvents", "service:app-events")
);
ALL_TARGETS.concat("service").forEach((t) =>
app.inject(t, "messageBus", "message-bus:main")
);

View File

@ -0,0 +1,11 @@
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
acceptance("current-user", function (needs) {
needs.user();
test("currentUser has appEvents", function (assert) {
let currentUser = this.container.lookup("current-user:main");
assert.ok(currentUser.appEvents);
});
});