diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index 35102e597..bbffb5be3 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -1,7 +1,6 @@ import { createWidget } from 'discourse/widgets/widget'; import { avatarAtts } from 'discourse/widgets/actions-summary'; import { h } from 'virtual-dom'; -import User from 'discourse/models/user'; const LIKE_ACTION = 2; @@ -308,7 +307,7 @@ export default createWidget('post-menu', { }, like() { - if (!User.current()) { + if (!this.currentUser) { return this.sendWidgetAction('showLogin'); } const attrs = this.attrs; diff --git a/test/javascripts/widgets/post-test.js.es6 b/test/javascripts/widgets/post-test.js.es6 index e644558f8..67886da76 100644 --- a/test/javascripts/widgets/post-test.js.es6 +++ b/test/javascripts/widgets/post-test.js.es6 @@ -181,6 +181,26 @@ widgetTest('liking', { } }); +widgetTest('anon liking', { + template: '{{mount-widget widget="post-menu" args=args showLogin="showLogin"}}', + anonymous: true, + setup() { + const args = { showLike: true }; + this.set('args', args); + this.on("showLogin", () => this.loginShown = true); + }, + test(assert) { + assert.ok(!!this.$('.actions button.like').length); + assert.ok(this.$('.actions button.like-count').length === 0); + + click('.actions button.like'); + andThen(() => { + assert.ok(this.loginShown); + }); + } +}); + + widgetTest('edit button', { template: '{{mount-widget widget="post" args=args editPost="editPost"}}', setup() {