FIX: PostActionCreator was not checking the guardian properly

It also exposed a bug in the EmailReceiver spec, where a test had a user
liking their own post and was not failing.
This commit is contained in:
Robin Ward 2019-01-31 14:47:41 -05:00
parent ec7f418a22
commit 720e896e17
2 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ class PostActionCreator
end end
def perform(action) def perform(action)
guardian.ensure_post_can_act!(@post, action, opts: { guardian.ensure_post_can_act!(@post, PostActionType.types[action], opts: {
taken_actions: PostAction.counts_for([@post].compact, @user)[@post&.id] taken_actions: PostAction.counts_for([@post].compact, @user)[@post&.id]
}) })

View File

@ -241,7 +241,7 @@ describe Email::Receiver do
let(:category) { Fabricate(:category) } let(:category) { Fabricate(:category) }
let(:user) { Fabricate(:user, email: "discourse@bar.com") } let(:user) { Fabricate(:user, email: "discourse@bar.com") }
let(:topic) { create_topic(category: category, user: user) } let(:topic) { create_topic(category: category, user: user) }
let(:post) { create_post(topic: topic, user: user) } let(:post) { create_post(topic: topic) }
let!(:post_reply_key) do let!(:post_reply_key) do
Fabricate(:post_reply_key, Fabricate(:post_reply_key,