FIX: `PostActionCreator` was not checking the guardian properly

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.

diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rb
index 32e4b2a..21b951a 100644
--- a/lib/post_action_creator.rb
+++ b/lib/post_action_creator.rb
@@ -7,7 +7,7 @@ class PostActionCreator
   end
 
   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]
     })
 
diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb
index 75ac46d..f243065 100644
--- a/spec/components/email/receiver_spec.rb
+++ b/spec/components/email/receiver_spec.rb
@@ -241,7 +241,7 @@ describe Email::Receiver do
     let(:category) { Fabricate(:category) }
     let(:user) { Fabricate(:user, email: "discourse@bar.com") }
     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
       Fabricate(:post_reply_key,

GitHub sha: 720e896e

1 Like