FIX: Skip post processing for non-regular posts (#57)

FIX: Skip post processing for non-regular posts (#57)

diff --git a/lib/category_experts/post_handler.rb b/lib/category_experts/post_handler.rb
index c7a87c7..35d7eeb 100644
--- a/lib/category_experts/post_handler.rb
+++ b/lib/category_experts/post_handler.rb
@@ -14,6 +14,8 @@ module CategoryExperts
         return unless ensure_poster_is_category_expert
       end
 
+      return unless post.post_type == Post.types[:regular]
+
       SiteSetting.category_experts_posts_require_approval ?
         mark_post_for_approval(skip_validations: skip_validations) :
         mark_post_as_approved(skip_validations: skip_validations)
diff --git a/spec/lib/post_handler_spec.rb b/spec/lib/post_handler_spec.rb
index 7110a90..9a314b6 100644
--- a/spec/lib/post_handler_spec.rb
+++ b/spec/lib/post_handler_spec.rb
@@ -52,6 +52,19 @@ describe CategoryExperts::PostHandler do
         expect(result.post.topic.custom_fields[CategoryExperts::TOPIC_FIRST_EXPERT_POST_ID]).to eq(existing_post.post_number)
         expect(result.post.topic.custom_fields[CategoryExperts::TOPIC_EXPERT_POST_GROUP_NAMES]).to eq(group.name)
       end
+
+      it "does nothing for non-regular posts" do
+        expect {
+          create_post(topic_id: topic.id, user: expert, post_type: Post.types[:small_action])
+          create_post(topic_id: topic.id, user: expert, post_type: Post.types[:whisper])
+          create_post(topic_id: topic.id, user: expert, post_type: Post.types[:moderator_action])
+        }.to change {
+          PostCustomField.where(name: [
+            CategoryExperts::POST_APPROVED_GROUP_NAME,
+            CategoryExperts::POST_PENDING_EXPERT_APPROVAL
+          ]).count
+        }.by(0)
+      end
     end
   end
 

GitHub sha: 6afe36213d026416bb7e8fff47a37a46248eeb8f

This commit appears in #57 which was approved by pmusaraj. It was merged by markvanlan.